(ctx context.Context, registrationClient tunnelrpc.RegistrationClient)
| 122 | } |
| 123 | |
| 124 | func (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 | |
| 149 | func (c *controlStream) IsStopped() bool { |
| 150 | return c.stoppedGracefully |
no test coverage detected