MCPcopy
hub / github.com/grafana/dskit / Shutdown

Method Shutdown

kv/memberlist/tcp_transport.go:627–652  ·  view source on GitHub ↗

Shutdown is called when memberlist is shutting down; this gives the transport a chance to clean up any listeners. This will avoid log spam about errors when we shut down.

()

Source from the content-addressed store, hash-verified

625// transport a chance to clean up any listeners.
626// This will avoid log spam about errors when we shut down.
627func (t *TCPTransport) Shutdown() error {
628 t.shutdownMu.Lock()
629 // This will avoid log spam about errors when we shut down.
630 if t.shutdown {
631 t.shutdownMu.Unlock()
632 return nil // already shut down
633 }
634
635 // Set the shutdown flag and close the write channel.
636 t.shutdown = true
637 close(t.writeCh)
638 t.shutdownMu.Unlock()
639
640 // Rip through all the connections and shut them down.
641 for _, conn := range t.tcpListeners {
642 _ = conn.Close()
643 }
644
645 // Wait until all write workers have finished.
646 t.writeWG.Wait()
647
648 // Block until all the listener threads have died.
649 t.wg.Wait()
650
651 return nil
652}
653
654func (t *TCPTransport) registerMetrics(registerer prometheus.Registerer) {
655 const subsystem = "memberlist_tcp_transport"

Calls 2

CloseMethod · 0.65
WaitMethod · 0.45