From a0ba6dee214f6bdac1637b019d2e95381a3074b8 Mon Sep 17 00:00:00 2001 From: evgeny Date: Wed, 5 Aug 2026 18:57:35 +0300 Subject: [PATCH] fix: tgc_phase1_timeout closing all handles including connected ones --- src/routing_layer/topo_group_connect.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/routing_layer/topo_group_connect.c b/src/routing_layer/topo_group_connect.c index ddb957d3..6f572be6 100644 --- a/src/routing_layer/topo_group_connect.c +++ b/src/routing_layer/topo_group_connect.c @@ -260,8 +260,16 @@ static void tgc_phase1_timeout(void* arg) { } u_free(ids); - for (int i = 0; i < gc->handle_count; i++) { conn_mgr_close(gc->handles[i]); gc->handles[i] = NULL; } - gc->handle_count = 0; + int remaining = 0; + for (int i = 0; i < gc->handle_count; i++) { + struct CONN_MGR_HANDLE* h = gc->handles[i]; + if (h && conn_mgr_get_conn(h) != NULL) { + gc->handles[remaining++] = h; + } else { + if (h) conn_mgr_close(h); + } + } + gc->handle_count = remaining; if (gc->connected_count > 0) { DEBUG_INFO(DEBUG_CATEGORY_BGP, "%s: Phase1 done — %d connected, skipping Phase 2", TGC_ID, gc->connected_count);