From 58b9f281494b0692287b55cd75c0ec053925521d Mon Sep 17 00:00:00 2001 From: Evgeny Date: Tue, 14 Jul 2026 18:22:05 +0300 Subject: [PATCH] fix chatgui: prevent invite deadlock on connection flap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit cs_on_conn_down: remove invite state zeroing on disconnection. Only timeout callbacks and explicit protocol end (CS_MSG_ERROR, transition to JOIN phase) clear the invite state. Connection flap now causes automatic retry: conn_up → pending_invite_ch_id != 0 && !info_req_timer → resend CHANNEL_INFO_REQ. No deadlock possible. --- AGENTS.md | 3 +++ tools/chatgui/transport/chat_sync.c | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 30fe79c6..fec126e8 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -12,6 +12,9 @@ This file contains essential information for AI coding agents working in the uTu Это devel. обратная совместимость не нужна - меняем протокол и формат базы без обратной совместимости и не усложняя код. +Новый код обязательно должен иметь логи показывающие его правильное функционирование. +Все ошибки и нештатное поведение должно логироваться + ## Quick Reference **Repository:** uTun - Secure VPN tunnel with ETCP protocol diff --git a/tools/chatgui/transport/chat_sync.c b/tools/chatgui/transport/chat_sync.c index f7aa378d..64d265ae 100644 --- a/tools/chatgui/transport/chat_sync.c +++ b/tools/chatgui/transport/chat_sync.c @@ -461,9 +461,9 @@ static void cs_on_conn_down(struct ETCP_CONN* conn, void* arg) { uint64_t peer = conn->peer_node_id; cs_cancel_proto_timers(g_cs); if (g_cs->pending_invite_node_id == peer) { - DEBUG_WARN(DEBUG_CATEGORY_CONNECTIVITY, "%s: conn down while waiting invite resp peer=%016llx", CS_ID, (unsigned long long)peer); - g_cs->pending_invite_node_id = 0; - g_cs->pending_invite_ch_id = 0; + DEBUG_WARN(DEBUG_CATEGORY_CONNECTIVITY, "%s: conn down while waiting invite resp peer=%016llx, timers cancelled, state kept for retry on reconnect", + CS_ID, (unsigned long long)peer); + /* invite state survives connection flaps: only timeout or explicit protocol end clears it */ } for (int i = 0; i < g_cs->channel_count; i++) { int found = 0;