mirror of
https://github.com/moby/moby.git
synced 2026-01-11 02:31:44 +00:00
fix: prevent potential panic in Shutdown when EventsService is nil
Add nil check before calling EventsService.Close() to prevent panic when daemon.EventsService is not initialized during shutdown. Signed-off-by: jinda.ljd <jinda.ljd@alibaba-inc.com>
This commit is contained in:
@@ -1498,7 +1498,9 @@ func (daemon *Daemon) Shutdown(ctx context.Context) error {
|
||||
// running anymore. If there are still some open connections to the
|
||||
// '/events' endpoint, closing the EventsService should tear them down
|
||||
// immediately.
|
||||
daemon.EventsService.Close()
|
||||
if daemon.EventsService != nil {
|
||||
daemon.EventsService.Close()
|
||||
}
|
||||
|
||||
return daemon.cleanupMounts(cfg)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user