// Close disconnects all peers.
// No new peers can be registered after Close has returned.
772454
func (ps *peerSet) Close() {
	ps.lock.Lock()
	defer ps.lock.Unlock()

	for _, p := range ps.peers {
		p.Disconnect(p2p.DiscQuitting)
	}
	ps.closed = true
}
551303
func (c *Client) Close() error {
	c.mu.Lock()
	if c.closed {
		c.mu.Unlock()
		return ftpError{err: errors.New("already closed")}
	}
	c.closed = true

	var conns []*persistentConn
	for _, conn := range c.allCons {
		conns = append(conns, conn)
	}
	c.mu.Unlock()

	for _, pconn := range conns {
		c.removeConn(pconn)
	}

	return nil
}
382240
func (c *Client) Close() error {
	c.mutex.Lock()
	defer c.mutex.Unlock()

	// check if connected
	if atomic.LoadUint32(&c.state) < clientConnecting {
		return ErrClientNotConnected
	}

	return c.end(nil, false)
}
897122
func (c *Client) Close() error {
	if err := c.LeaveRealm(); err != nil {
		return err
	}
	if err := c.Peer.Close(); err != nil {
		return fmt.Errorf("error closing client connection: %v", err)
	}
	return nil
}
1136296
func (rpcClient *ReconnectRPCClient) Close() (err error) {
	rpcClient.mutex.Lock()
	netRPCClient := rpcClient.netRPCClient
	rpcClient.mutex.Unlock()

	if netRPCClient != nil {
		var status bool
		netRPCClient.Call("LockServer.Logout", &rpcClient.sessionID, &status)

		rpcClient.mutex.Lock()
		rpcClient.netRPCClient = nil
		rpcClient.mutex.Unlock()

		netRPCClient.Close()
	}

	return nil
}
619198
func (p *Pool) Close() {
	p.mu.Lock()
	defer p.mu.Unlock()

	for _, c := range p.connections {
		p.errorChannel <- c.removeFromPool()
	}
	close(p.errorChannel)
}
138913
func (b *Bucket) Close() {
	b.Lock()
	defer b.Unlock()
	if b.connPools != nil {
		for _, c := range b.getConnPools(true /* already locked */) {
			if c != nil {
				c.Close()
			}
		}
		b.connPools = nil
	}
}
251833
func (c *Client) Close() error {
	defer close(c.notify)

	_, err := c.Exec("quit")
	err2 := c.conn.Close()

	if err != nil {
		return err
	}

	return err2
}
1087827
func (s *Server) Close(ctx context.Context) error {
	return s.Shutdown(ctx)
}
571965
func (c *Pipeline) Close() error {
	c.mu.Lock()
	c.discard()
	c.closed = true
	c.mu.Unlock()
	return nil
}
1265614
func (node *Node) Close() {
	if node.conn != nil {
		node.conn.Close()
	}

	node.conn = nil
}
879365
func (c SyncConn) Close() error {
	return errors.CombineErrs("error closing SyncConn", errors.NetworkError,
		c.SyncScanner.Close(), c.SyncSender.Close())
}
1227952
func (forwarder *BufferedForwarder) Close() error {
	forwarder.stopFunc()
	forwarder.threadsWaitingToDie.Wait()
	return forwarder.closeSender()
}
46108
func (p *TSocket) Close() error {
	// Close the socket
	if p.conn != nil {
		err := p.conn.Close()
		if err != nil {
			return err
		}
		p.conn = nil
	}
	return nil
}
602573
func (e *endpoint) Close() {
	// Issue a shutdown so that the peer knows we won't send any more data
	// if we're connected, or stop accepting if we're listening.
	e.Shutdown(tcpip.ShutdownWrite | tcpip.ShutdownRead)

	e.mu.Lock()

	// For listening sockets, we always release ports inline so that they
	// are immediately available for reuse after Close() is called. If also
	// registered, we unregister as well otherwise the next user would fail
	// in Listen() when trying to register.
	if e.state == stateListen && e.isPortReserved {
		if e.isRegistered {
			e.stack.UnregisterTransportEndpoint(e.boundNICID, e.effectiveNetProtos, ProtocolNumber, e.id, e)
			e.isRegistered = false
		}

		e.stack.ReleasePort(e.effectiveNetProtos, ProtocolNumber, e.id.LocalAddress, e.id.LocalPort)
		e.isPortReserved = false
	}

	// Either perform the local cleanup or kick the worker to make sure it
	// knows it needs to cleanup.
	tcpip.AddDanglingEndpoint(e)
	if !e.workerRunning {
		e.cleanupLocked()
	} else {
		e.workerCleanup = true
		e.notifyProtocolGoroutine(notifyClose)
	}

	e.mu.Unlock()
}
767349
func (r *FilteredConn) Close() error {
	select {
	case <-r.closed:
		return errClosed
	default:
	}
	close(r.closed)
	r.source.removeConn(r)
	return nil
}
839232
func (p *V2) Close() error {
	p.Lock()
	defer p.Unlock()

	for _, location := range p.locations {
		if err := location.Close(); err != nil {
			return err
		}
	}

	for _, group := range p.groups {
		if err := group.Close(); err != nil {
			return err
		}
	}

	for _, dev := range p.devices {
		if err := dev.Close(); err != nil {
			return err
		}
	}

	if err := p.broadcast.Close(); err != nil {
		return err
	}

	select {
	case <-p.quitChan:
		common.Log.Warnf(`protocol already closed`)
		return common.ErrClosed
	default:
		close(p.quitChan)
		p.wg.Wait()
		close(p.deviceQueue)
	}

	return p.SubscriptionProvider.Close()
}