Skip to content

Commit

Permalink
Fix hangs on SIGTERM.
Browse files Browse the repository at this point in the history
This fixes #1469, where three bugs pervent main from existing on
SIGTERM.

The first two are blocking receiving from cancel chanels which never
have values sent to them, cancelStateUpdateChan and
cancelPolicyUpdateChan. It seems closing the chanels should be all the
is needed to signal the watching goroutines to exit.

The other is the signal hander never exiting an infinite for loop. The
sigFunc is called in an errorGroup which blocks exiting Serve and thus
main. It looks like a refactor in #1382 removed an os.Exit(0),
replacing it with a return breaks out of the loop.
  • Loading branch information
armooo authored and kradalby committed Jul 7, 2023
1 parent 23a3adf commit 5630f9e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion hscontrol/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,6 @@ func (h *Headscale) Serve() error {
// Stop listening (and unlink the socket if unix type):
socketListener.Close()

<-h.cancelStateUpdateChan
close(h.stateUpdateChan)
close(h.cancelStateUpdateChan)

Expand All @@ -775,6 +774,7 @@ func (h *Headscale) Serve() error {

// And we're done:
cancel()
return
}
}
}
Expand Down

0 comments on commit 5630f9e

Please sign in to comment.