From 4c623e25ceeff257a46a407a261f6665b6d66096 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Fri, 24 Jul 2026 13:56:29 +0300 Subject: [PATCH] chatgui: add shutdown diagnostics (poll exit reason, cleanup steps, app.exec return) --- tools/chatgui/src/main.cpp | 4 +++- tools/chatgui/src/mainwindow.cpp | 1 + tools/chatgui/transport/utun_node.cpp | 7 +++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/tools/chatgui/src/main.cpp b/tools/chatgui/src/main.cpp index 1f9ef5d5..10fbec40 100644 --- a/tools/chatgui/src/main.cpp +++ b/tools/chatgui/src/main.cpp @@ -95,5 +95,7 @@ int main(int argc, char *argv[]) { SetConsoleCtrlHandler(console_ctrl_handler, TRUE); #endif - return app.exec(); + int ret = app.exec(); + qDebug("main: app.exec() returned %d", ret); + return ret; } diff --git a/tools/chatgui/src/mainwindow.cpp b/tools/chatgui/src/mainwindow.cpp index add220b0..65002eee 100644 --- a/tools/chatgui/src/mainwindow.cpp +++ b/tools/chatgui/src/mainwindow.cpp @@ -88,6 +88,7 @@ MainWindow::~MainWindow() { if (m_messageList) m_messageList->saveChannelState(); DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, "MainWindow: ~MainWindow — stopping utun node"); if (m_node) { m_node->stop(); delete m_node; m_node = nullptr; } + DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, "MainWindow: ~MainWindow — node stop+delete done"); DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, "MainWindow: ~MainWindow done"); } diff --git a/tools/chatgui/transport/utun_node.cpp b/tools/chatgui/transport/utun_node.cpp index 482deee7..778607c2 100644 --- a/tools/chatgui/transport/utun_node.cpp +++ b/tools/chatgui/transport/utun_node.cpp @@ -344,16 +344,23 @@ void UtunNode::runLoop() { uasync_poll(ua, 100); } + DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "runLoop: poll exit m_stop=%d g_shutdown=%d", (int)m_stop, (int)g_shutdown); + signal(SIGINT, SIG_DFL); signal(SIGTERM, SIG_DFL); g_signal_ua = nullptr; etcp_router_bind(m_instance, ETCP_RT_ID_CHAT, nullptr); + DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "runLoop: etcp_router_unbind done"); chat_sync_destroy(m_instance); + DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "runLoop: chat_sync_destroy done"); chat_core_destroy(m_instance); + DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "runLoop: chat_core_destroy done"); utun_instance_destroy(m_instance); + DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "runLoop: utun_instance_destroy done"); m_instance = nullptr; uasync_destroy(ua, 0); + DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "runLoop: uasync_destroy done, emitting stopped"); g_currentNode = nullptr; QMetaObject::invokeMethod(this, [this] { emit stopped(); }); }