Skip to content

Commit 5c637b7

Browse files
committed
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>
1 parent 3bd2edb commit 5c637b7

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

daemon/daemon.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1498,7 +1498,9 @@ func (daemon *Daemon) Shutdown(ctx context.Context) error {
14981498
// running anymore. If there are still some open connections to the
14991499
// '/events' endpoint, closing the EventsService should tear them down
15001500
// immediately.
1501-
daemon.EventsService.Close()
1501+
if daemon.EventsService != nil {
1502+
daemon.EventsService.Close()
1503+
}
15021504

15031505
return daemon.cleanupMounts(cfg)
15041506
}

0 commit comments

Comments
 (0)