// ConnectionClosed is part of the mysql.Handler interface.
494773
func (db *DB) ConnectionClosed(c *mysql.Conn) {
	db.mu.Lock()
	defer db.mu.Unlock()

	if db.t != nil {
		db.t.Logf("ConnectionClosed(%v): client %v", db.name, c.ConnectionID)
	}

	if _, ok := db.connections[c.ConnectionID]; !ok {
		db.t.Fatalf("BUG: Cannot delete connection from list of open connections because it is not registered. ID: %v Conn: %v", c.ConnectionID, c)
	}
	delete(db.connections, c.ConnectionID)
}
434314
func (c *Conn) Close() error {
	select {
	case <-c.chDone:
		// Return if it's already closed.
		return nil
	default:
		c.hci.Send(&cmd.Disconnect{
			ConnectionHandle: c.param.ConnectionHandle(),
			Reason:           0x13,
		}, nil)
		return nil
	}
}
336633
func (c *Conn) initClosing() {
	c.closingmu.Lock()
	if c.closing == nil {
		c.closing = make(chan struct{})
	}
	c.closingmu.Unlock()
}
261620
func (c *Connection) Close() error {
	if !c.returnOnClose {
		if c.Conn != nil {
			return c.Conn.Close()
		}
		return nil
	}
	c.owner.Release(c, nil)
	return nil
}
584291
func (c *Conn) Close() {
	if c.closed.CompareAndSwap(false, true) {
		c.conn.Close()
	}
}
538807
func (nc *Conn) IsClosed() bool {
	nc.mu.RLock()
	defer nc.mu.RUnlock()
	return nc.isClosed()
}
1154073
func (c *Client) Close() error {
	if c.conn == nil {
		return ErrAlreadyClosed
	}
	err := c.conn.Close()
	c.conn = nil
	return err
}
1001329
func (c *mongoDBConnectionProducer) Close() error {
	c.Lock()
	defer c.Unlock()

	if c.session != nil {
		c.session.Close()
	}

	c.session = nil

	return nil
}
1107522
func (rows *Rows) Close() {
	if rows.closed {
		return
	}

	if rows.unlockConn {
		rows.conn.unlock()
		rows.unlockConn = false
	}

	rows.closed = true

	rows.err = rows.conn.termContext(rows.err)

	if rows.err == nil {
		if rows.conn.shouldLog(LogLevelInfo) {
			endTime := time.Now()
			rows.conn.log(LogLevelInfo, "Query", map[string]interface{}{"sql": rows.sql, "args": logQueryArgs(rows.args), "time": endTime.Sub(rows.startTime), "rowCount": rows.rowCount})
		}
	} else if rows.conn.shouldLog(LogLevelError) {
		rows.conn.log(LogLevelError, "Query", map[string]interface{}{"sql": rows.sql, "args": logQueryArgs(rows.args)})
	}

	if rows.batch != nil && rows.err != nil {
		rows.batch.die(rows.err)
	}

	if rows.connPool != nil {
		rows.connPool.Release(rows.conn)
	}
}
693437
func (c *boltConn) Close() error {

	if c.closed {
		return nil
	}

	if c.statement != nil {
		if err := c.statement.Close(); err != nil {
			return err
		}
	}

	if c.transaction != nil {
		if err := c.transaction.Rollback(); err != nil {
			return errors.Wrap(err, "Error rolling back transaction when closing connection")
		}
	}

	if c.poolDriver != nil {
		// If using connection pooling, don't close connection, just reclaim it
		err := c.poolDriver.reclaim(c)
		if err != nil {
			log.Errorf("An error occurred reclaiming connection for pool: %s", err)
			c.connErr = errors.Wrap(err, "An error occurred closing the connection")
			return driver.ErrBadConn
		}
		return nil
	}

	err := c.conn.Close()
	c.closed = true
	if err != nil {
		c.connErr = errors.Wrap(err, "An error occurred closing the connection")
		return driver.ErrBadConn
	}

	return nil
}
666011
func (c *Transport) CloseIdleConnections() (closed, remaining int) {
	c.connMutex.Lock()
	defer c.connMutex.Unlock()

	for i := 0; i < len(c.connections); {
		conn := c.connections[i]
		if conn.IsClosed() || conn.IsIdle(c.IdleConnTimeout) {
			// Remove connection from list
			c.connections = append(c.connections[:i], c.connections[i+1:]...)
			// Close connection
			go conn.Close()
			closed++
		} else {
			i++
		}
	}

	remaining = len(c.connections)
	return closed, remaining
}
179133
func (db *DB) Close() {
	if db.closed {
		return
	}

	db.closed = true
	C.leveldb_close(db.Ldb)
}
327988
func (db *DB) CloseAllConnections() {
	db.mu.Lock()
	defer db.mu.Unlock()

	for _, c := range db.connections {
		c.Close()
	}
}
373781
func (c *Conn) Close() error {
	if c != nil {
		return c.sqlite.Close()
	}
	return nil
}
612356
func (s session) Close() error {
	if s.Connection == nil {
		return nil
	}
	return s.Connection.Close()
}
918122
func (c *GRPCConnection) Close() {
	if !c.setClosed() {
		logger.Debug("Already closed")
		return
	}

	logger.Debug("Releasing connection....")
	c.commManager.ReleaseConn(c.conn)

	logger.Debug("... connection successfully closed.")
}
913636
func (c *Client) Close() error {
	if c.connection != nil {
		return c.connection.Close()
	}
	return nil
}