// doShutdown closes the shutdown channel and logs the shutdown unless shutdown
// is already in progress.  It will return false if the shutdown is not needed.
//
// This function is safe for concurrent access.
181397
func (c *Client) doShutdown() bool {
	// Ignore the shutdown request if the client is already in the process
	// of shutting down or already shutdown.
	select {
	case <-c.shutdown:
		return false
	default:
	}

	log.Tracef("Shutting down RPC client %s", c.config.Host)
	close(c.shutdown)
	return true
}
955877
func (md *MDServerDisk) Shutdown() {
	md.lock.Lock()
	defer md.lock.Unlock()
	if md.handleDb == nil {
		return
	}

	// Make further accesses error out.

	md.handleDb.Close()
	md.handleDb = nil

	md.branchDb.Close()
	md.branchDb = nil

	tlfStorage := md.tlfStorage
	md.tlfStorage = nil

	for _, s := range tlfStorage {
		s.shutdown()
	}

	if md.shutdownFunc != nil {
		md.shutdownFunc(md.log)
	}
}
294808
func (c *client) shutdown() {
	c.closeLock.Lock()
	defer c.closeLock.Unlock()

	if c.closed {
		return
	}
	c.closed = true
	close(c.closedCh)

	if c.ipv4conn != nil {
		c.ipv4conn.Close()
	}
	if c.ipv6conn != nil {
		c.ipv6conn.Close()
	}
}
872249
func (s *ExtensionManagerServer) Shutdown(ctx context.Context) error {
	s.mutex.Lock()
	defer s.mutex.Unlock()
	if s.server != nil {
		server := s.server
		s.server = nil
		// Stop the server asynchronously so that the current request
		// can complete. Otherwise, this is vulnerable to deadlock if a
		// shutdown request is being processed when shutdown is
		// explicitly called.
		go func() {
			server.Stop()
		}()
	}

	return nil
}
1195478
func (s *InstancesCount) SetShuttingDown(v int64) *InstancesCount {
	s.ShuttingDown = &v
	return s
}
542105
func (h *HandlerCommon) ShutDown() {
	h.mu.Lock()
	if h.shutdown {
		log.Printf("Warning: server received a shutdown request after it was already shut down.")
	}
	h.shutdown = true
	h.mu.Unlock()
}
1117858
func (c *Connector) Shutdown() error {
	if c.Next == nil {
		return NewErrNoMoreConnector()
	}
	return c.Next.Shutdown()
}
1122631
func (b *ETCDBindingStorage) Shutdown() error {
	close(b.stopChan)
	return b.cli.Close()
}
712125
func (t *requestTracker) shutdown(reason error) {
	t.shutdownReason.Store(&reason)
	t.commandChan <- shutdown
}
699456
func (c *Controller) Shutdown(ctx context.Context) error {
	return c.c.Shutdown(ctx)
}
80954
func (g *GoogleCloud) Shutdown() {
	g.shutdown = true

	var wg sync.WaitGroup
	for k, v := range g.subs {
		wg.Add(1)
		logrus.Infof("Shutting down sub for %s", k)
		go func(c context.CancelFunc) {
			c()
			wg.Done()
		}(v)
	}
	wg.Wait()
	return
}
127636
func (d *ImpatientDebugDumper) Shutdown() {
	if d.shutdownFunc != nil {
		d.shutdownFunc()
		<-d.shutdownDoneCh
	}
}
522817
func (s *PrioritySlot) Shutdown() {
	s.mu.Lock()
	defer s.mu.Unlock()
	if s.cancel != nil {
		s.cancel()
		s.cancel = nil
		s.priority = 0
	}
	s.shutdown = true
}
90192
func (cc *clientConn) ShutdownOrNotify() bool {
	if (cc.ctx.Status() & mysql.ServerStatusInTrans) > 0 {
		return false
	}
	// If the client connection status is reading, it's safe to shutdown it.
	if atomic.CompareAndSwapInt32(&cc.status, connStatusReading, connStatusShutdown) {
		return true
	}
	// If the client connection status is dispatching, we can't shutdown it immediately,
	// so set the status to WaitShutdown as a notification, the client will detect it
	// and then exit.
	atomic.StoreInt32(&cc.status, connStatusWaitShutdown)
	return false
}
48920
func (l *Listener) Shutdown() {
	if l.shutdown.CompareAndSwap(false, true) {
		l.Close()
	}
}
1323421
func (md *MDServerDisk) isShutdown() bool {
	md.lock.RLock()
	defer md.lock.RUnlock()
	return md.checkShutdownLocked() != nil
}
61089
func (router *Router) Shutdown() error {
	if router.httpServer == nil {
		return nil
	}
	timer := router.config.ShutdownTimeout

	ctx, cancel := context.WithTimeout(context.Background(), timer)
	defer cancel()

	err := router.httpServer.Shutdown(ctx)
	if err != nil {
		LOGHANDLER.Error(err)
	}
	return err
}