Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Commit

Permalink
Make upstream.Close() wait for shutdown
Browse files Browse the repository at this point in the history
We let main() exit, and block on graceful shutdown in a `defer`ed
procedure. We _also_ `defer` a call to `upstream.Close()`, which stops
the upstream reconnecting and closes it.

The two deferred procedure calls used to be in such an order that by
coincidence, `upstream.Close()` was _also_ blocked on graceful
shutdown. But this order was shuffled in PR #962.

This commit makes the `upstream.Close()` explicitly wait for shutdown.
  • Loading branch information
squaremo committed Mar 20, 2018
1 parent 866da34 commit a2c82a7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion cmd/fluxd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,10 @@ func main() {
os.Exit(1)
}
daemon.EventWriter = upstream
defer upstream.Close()
go func() {
<-shutdown
upstream.Close()
}()
} else {
logger.Log("upstream", "no upstream URL given")
}
Expand Down

0 comments on commit a2c82a7

Please sign in to comment.