summaryrefslogtreecommitdiff
path: root/pkg/api/server
diff options
context:
space:
mode:
authorMatthew Heon <mheon@redhat.com>2021-01-25 15:29:00 -0500
committerMatthew Heon <matthew.heon@pm.me>2021-01-29 15:24:24 -0500
commit07f2df472cdbb4c1e533dbb6e17a6c04bd2f76fe (patch)
treee214ebdd47ce40da11cac2d533cfbe4dd54b16f9 /pkg/api/server
parentc48753bfa0d56b855f71dc6ad62e8eff62cf98e1 (diff)
downloadpodman-07f2df472cdbb4c1e533dbb6e17a6c04bd2f76fe.tar.gz
podman-07f2df472cdbb4c1e533dbb6e17a6c04bd2f76fe.tar.bz2
podman-07f2df472cdbb4c1e533dbb6e17a6c04bd2f76fe.zip
Ensure shutdown handler access is syncronized
There was a potential race where two handlers could be added at the same time. Go Maps are not thread-safe, so that could do unpleasant things. Add a mutex to keep things safe. Also, swap the order or Register and Start for the handlers in Libpod runtime created. As written, there was a small gap between Start and Register where SIGTERM/SIGINT would be completely ignored, instead of stopping Podman. Swapping the two closes this gap. Signed-off-by: Matthew Heon <mheon@redhat.com>
Diffstat (limited to 'pkg/api/server')
-rw-r--r--pkg/api/server/server.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/pkg/api/server/server.go b/pkg/api/server/server.go
index 046f6561c..d612041f6 100644
--- a/pkg/api/server/server.go
+++ b/pkg/api/server/server.go
@@ -179,15 +179,15 @@ func setupSystemd() {
func (s *APIServer) Serve() error {
setupSystemd()
- // Start the shutdown signal handler.
- if err := shutdown.Start(); err != nil {
- return err
- }
if err := shutdown.Register("server", func(sig os.Signal) error {
return s.Shutdown()
}); err != nil {
return err
}
+ // Start the shutdown signal handler.
+ if err := shutdown.Start(); err != nil {
+ return err
+ }
errChan := make(chan error, 1)