MCPcopy
hub / github.com/cloudflare/cloudflared / waitForUnregister

Method waitForUnregister

connection/control.go:124–147  ·  view source on GitHub ↗
(ctx context.Context, registrationClient tunnelrpc.RegistrationClient)

Source from the content-addressed store, hash-verified

122}
123
124func (c *controlStream) waitForUnregister(ctx context.Context, registrationClient tunnelrpc.RegistrationClient) error {
125 // wait for connection termination or start of graceful shutdown
126 defer registrationClient.Close()
127 var shutdownError error
128 select {
129 case <-ctx.Done():
130 shutdownError = ctx.Err()
131 break
132 case <-c.gracefulShutdownC:
133 c.stoppedGracefully = true
134 }
135
136 c.observer.sendUnregisteringEvent(c.connIndex)
137 err := registrationClient.GracefulShutdown(ctx, c.gracePeriod)
138 if err != nil {
139 return errors.Wrap(err, "Error shutting down control stream")
140 }
141 c.observer.log.Info().
142 Int(management.EventTypeKey, int(management.Cloudflared)).
143 Uint8(LogFieldConnIndex, c.connIndex).
144 IPAddr(LogFieldIPAddress, c.edgeAddress).
145 Msg("Unregistered tunnel connection")
146 return shutdownError
147}
148
149func (c *controlStream) IsStopped() bool {
150 return c.stoppedGracefully

Callers 1

ServeControlStreamMethod · 0.95

Calls 5

IntMethod · 0.80
CloseMethod · 0.65
GracefulShutdownMethod · 0.65
ErrMethod · 0.45

Tested by

no test coverage detected