TUN-3738: Consume UI events even when UI is disabled

Not doing so was causing cloudflared to become stuck after
some time. This would happen because the Observer pattern
was sending events to the UI channel (that has 16 slots) but
no one was consuming those when the UI is not enabled (which
is the default case).

Hence, events (such as connection disconnect / reconnect) would
cause that buffer to be full and cause cloudflared to become
apparently stuck, in the sense that the connections would not be
reconnected.
This commit is contained in:
Nuno Diegues 2021-01-13 13:10:30 +00:00
parent 119d96cdc1
commit 9ed536c990
1 changed files with 6 additions and 0 deletions

View File

@ -377,6 +377,12 @@ func StartServer(
tunnelConfig.HAConnections, tunnelConfig.HAConnections,
) )
tunnelInfo.LaunchUI(ctx, log, transportLog, uiCh) tunnelInfo.LaunchUI(ctx, log, transportLog, uiCh)
} else {
go func() {
for range uiCh {
// Consume UI events into a noop
}
}()
} }
return waitToShutdown(&wg, errC, shutdownC, graceShutdownC, c.Duration("grace-period"), log) return waitToShutdown(&wg, errC, shutdownC, graceShutdownC, c.Duration("grace-period"), log)