// Close closes the client, releasing any open resources.
//
// It is rare to Close a Client, as the Client is meant to be
// long-lived and shared between many goroutines.
189128
func (c *baseClient) Close() error {
	var firstErr error
	if c.onClose != nil {
		if err := c.onClose(); err != nil {
			firstErr = err
		}
	}
	if err := c.connPool.Close(); err != nil && firstErr == nil {
		firstErr = err
	}
	return firstErr
}
164385
func (c *RawKVClient) Close() error {
	c.pdClient.Close()
	return c.rpcClient.Close()
}
518371
func (c *client) Close() error {
	c.once.Do(func() {
		close(c.stop)
		if err := c.conn.Write(pdu.NewUnbind()); err == nil {
			select {
			case <-c.inbox: // TODO: validate UnbindResp
			case <-time.After(time.Second):
			}
		}
		c.conn.Close()
	})
	return nil
}
462148
func (client Client) Close() error {
	err := client.Sender.Close()
	return errors.Trace(err)
}
1235756
func (s *Server) Close() error {
	s.locker.Lock()
	defer s.locker.Unlock()

	for l := range s.listeners {
		l.Close()
	}

	for conn := range s.conns {
		conn.Close()
	}

	return nil
}
222682
func (ref *EventClientRef) Close() {
	if !atomic.CompareAndSwapInt32(&ref.closed, 0, 1) {
		// Already closed
		return
	}

	logger.Debug("Closing the event client")
	ref.ref.Close()
}
455789
func (c *Client) Close() (err error) {
	if c.text != nil {
		c.printfLine("close")
		err = c.text.Close()
		c.text = nil
	}
	return
}
1148079
func (c *client) close() {
	if c.leaser != nil {
		c.leaser.Close()
	}
	if c.watcher != nil {
		c.watcher.Close()
	}
	if c.wcf != nil {
		c.wcf()
	}
}
1151979
func (sr *SimpleRedis) Close() error {
	return safeclose.Close(sr.client, sr.respChan, sr.closeChan)
}
877829
func (c *Client) Close() error {
	for _, s := range c.subs {
		s.Unsubscribe()
	}
	return nil
}
255535
func (c *Client) Close() error {
	if c == nil {
		return fmt.Errorf("Client is nil")
	}
	select {
	case c.stop <- struct{}{}:
	default:
	}

	// if this client is buffered, flush before closing the writer
	if c.bufferLength > 0 {
		if err := c.Flush(); err != nil {
			return err
		}
	}

	return c.writer.Close()
}
102393
func (c *RPCClient) Close() error {
	c.shutdownLock.Lock()
	defer c.shutdownLock.Unlock()

	if !c.shutdown {
		c.shutdown = true
		close(c.shutdownCh)
		c.deregisterAll()
		return c.conn.Close()
	}
	return nil
}
1215299
func (api *LocalClient) Close() error {
	if api.legacyClient != nil {
		return api.legacyClient.Close()
	}
	return nil
}
987851
func (client *WebSocketClient) Close() {
	client.closed = true
	client.close(rpc.ErrClientIsAlreadyClosed)
}
635084
func (s *Server) Close() {
	close(s.closing)
	s.listener.Close()
	// We need to remove the socket path because
	// we renamed the path after opening the
	// socket and it won't be cleaned up automatically.
	// Ignore error as we can't do much here
	// anyway and remove the path if we start the
	// server again.
	os.Remove(s.socketPath)
	<-s.closed
}
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)
}
712465
func (c *engineRPC) Close() error {
	if c.client == nil {
		return fmt.Errorf("No client to close")
	}
	if err := c.client.Close(); err != nil {
		return fmt.Errorf("Close failed: %v", err)
	}
	c.client = nil
	c.conn = nil
	return nil
}