From 2b97b774663b44c86eb3f8029d690bbe9a433ec8 Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Wed, 2 Apr 2025 21:46:41 +0800 Subject: fix: nullptr(SEGEV) during shutdown --- src/sessionManager.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/sessionManager.cpp') diff --git a/src/sessionManager.cpp b/src/sessionManager.cpp index d880640..49d65b1 100644 --- a/src/sessionManager.cpp +++ b/src/sessionManager.cpp @@ -8,12 +8,17 @@ #include void CSessionManager::shutdownSessions() { + if (m_vSessions.empty()) + return; + for (auto &session : m_vSessions) kick(&session, false, "Server shutting down"); } CSessionManager::CSessionManager() { - if (std::atexit([]() { g_pSessionManager->shutdownSessions(); })) + if (std::atexit([]() { + if (g_pSessionManager) g_pSessionManager->shutdownSessions(); + })) log(ERR, "Failed to register SessionManager atexit handler, will fallback to quick_exit after hang"); log(LOG, "SessionManager: initialized"); -- cgit v1.2.3