// CloseAllConnections can be used to provoke MySQL client errors for open
// connections.
// Make sure to call WaitForShutdown() as well.
327988
func (db *DB) CloseAllConnections() {
	db.mu.Lock()
	defer db.mu.Unlock()

	for _, c := range db.connections {
		c.Close()
	}
}
178262
func (c *IdleTimingConn) Close() error {
	c.closeMutex.Lock()
	defer c.closeMutex.Unlock()

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

	c.closed = true

	select {
	case c.closedCh <- true:
		// close accepted
	default:
		// already closing, ignore
	}
	return c.conn.Close()
}
584291
func (c *Conn) Close() {
	if c.closed.CompareAndSwap(false, true) {
		c.conn.Close()
	}
}
17982
func (client *Client) closeConnection(connectionID int) error {
	request := newOpClientRequest(opClientCloseConnection, connectionID)
	client.opRequests <- request
	response := <-request.response
	if val, ok := response.(error); ok {
		return val
	}
	return nil
}
970698
func (d *Dialer) CloseAll() {
	d.mu.Lock()
	conns := d.conns
	d.conns = make(map[*closableConn]struct{})
	d.mu.Unlock()

	for conn := range conns {
		conn.Close()
	}
}
472908
func (m *model) closeConns(devs []protocol.DeviceID, err error) {
	conns := make([]connections.Connection, 0, len(devs))
	m.pmut.Lock()
	for _, dev := range devs {
		if conn, ok := m.conn[dev]; ok {
			conns = append(conns, conn)
		}
	}
	m.pmut.Unlock()
	for _, conn := range conns {
		conn.Close(err)
	}
}
1268285
func (c *Conn) Close() error {
	return c.opError(opClose, c.fd.Close())
}
22026
func (c *Client) SetCloseConnection(close bool) *Client {
	c.closeConnection = close
	return c
}
191854
func (conn *Connection) Close() {
	subs := []string{}

	conn.subMu.Lock()

	for s := range conn.chanSubscriptions {
		subs = append(subs, s)
	}

	for s := range conn.subscriptions {
		subs = append(subs, s)
	}

	conn.subMu.Unlock()

	for _, s := range subs {
		err := conn.Unsubscribe(s)
		if err != nil {
			conn.logger.Warnf("Could not unsubscribe from %s: %s", s, err)
		}
	}


	conn.Flush()

	conn.conMu.Lock()
	defer conn.conMu.Unlock()

	conn.logger.Debug("Closing NATS connection")
	conn.nats.Close()
}
328046
func (c *Client) Close() {
	for _, cns := range c.freeconn {
		for _, cn := range cns {
			c.cleanupFreeConn(cn.nc)
		}
	}
}
855614
func (c *Conn) Close() error {
	if c == nil {
		return nil
	}
	c.Closed = true
	if c.Conn != nil {
		return c.Conn.Close()
	}
	return nil
}
809436
func (c *clientConn) Close() error {
	defer c.wg.Wait()
	return c.conn.Close()
}
1187498
func (connection *redisConnection) CloseAllQueuesInConnection() error {
	connection.redisClient.Del(connection.queuesKey)
	// debug(fmt.Sprintf("connection closed all queues %s %d", connection, connection.queuesKey)) // COMMENTOUT
	return nil
}
1169325
func (db *BytesConnectionRedis) Close() error {
	if db.closed {
		db.Debug("Close() called on a closed connection")
		return nil
	}
	db.Debug("Close()")
	db.closed = true
	safeclose.Close(db.closeCh)
	if db.client != nil {
		err := safeclose.Close(db.client)
		if err != nil {
			return fmt.Errorf("Close() encountered error: %s", err)
		}
	}
	return nil
}
104035
func (dc *DefaultConnector) Close() <-chan bool {
	closed := make(chan bool)
	go func() {
		dc.bootstrapBrokers = nil
		closed <- true
	}()

	return closed
}
924596
func (s *server) OnClientConnectionClosed(callback func(c *Client, err error)) {
	s.onClientConnectionClosed = callback
}
517506
func (t *Transport) CloseIdleConnections() {
	t.lk.Lock()
	defer t.lk.Unlock()
	if t.idleConn == nil {
		return
	}
	for _, conns := range t.idleConn {
		for _, pconn := range conns {
			pconn.close()
		}
	}
	t.idleConn = make(map[string][]*persistConn)
}