From 90520a83ffc5f041461d195b23e73283d56fccfb Mon Sep 17 00:00:00 2001 From: evgeny Date: Sat, 19 Sep 2026 23:40:06 +0300 Subject: [PATCH] =?UTF-8?q?topo=5Fgroup=5Fconnect:=20=D0=BD=D0=B5=20=D0=BF?= =?UTF-8?q?=D0=BE=D0=B4=D0=BA=D0=BB=D1=8E=D1=87=D0=B0=D1=82=D1=8C=D1=81?= =?UTF-8?q?=D1=8F=20=D0=BA=20=D1=81=D0=B0=D0=BC=D0=BE=D0=BC=D1=83=20=D1=81?= =?UTF-8?q?=D0=B5=D0=B1=D0=B5=20=D0=B2=20=D0=B0=D0=B2=D1=82=D0=BE-=D1=86?= =?UTF-8?q?=D0=B8=D0=BA=D0=BB=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Phase 1/2/3 и on_up/on_down не фильтровали self: узел попадал в список connected-пиров (get_connected_peers не исключает self) и разворачивал node_conn_direct_open на собственные адреса (12 линков на 5C31->5C31). Ручной путь (connect_node_once) фильтр уже имел. Добавлен skip self в Phase1 init/cycle_restart, Phase2, Phase3 и в on_up/on_down (self не помечается connected и не считается в active_conn_count). --- src/routing_layer/topo_group_connect.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/routing_layer/topo_group_connect.c b/src/routing_layer/topo_group_connect.c index 7230a1c0..0373ef41 100644 --- a/src/routing_layer/topo_group_connect.c +++ b/src/routing_layer/topo_group_connect.c @@ -189,13 +189,17 @@ int topo_group_connect_init(struct TOPO_GROUP* group) { return 0; } - gc->phase = TGC_PHASE_ONE; gc->pending = count; + gc->phase = TGC_PHASE_ONE; + int launched = 0; DEBUG_INFO(DEBUG_CATEGORY_BGP, "%s: Phase 1 launching %d connects ch=%s grp=%016llx", TGC_ID, count, group->channel_id, (unsigned long long)group->group_id); for (int i = 0; i < count && gc->handle_count < TGC_MAX_HANDLES; i++) { + if (ids[i] == group->instance->node_id) { DEBUG_DEBUG(DEBUG_CATEGORY_BGP, "%s: Phase1 skip self 0x%016llx", TGC_ID, (unsigned long long)ids[i]); continue; } DEBUG_DEBUG(DEBUG_CATEGORY_BGP, "%s: Phase1 connect to 0x%016llx (%d/%d)", TGC_ID, (unsigned long long)ids[i], i + 1, count); node_conn_direct_open(group->instance, ids[i], tgc_callback, gc, &gc->handles[gc->handle_count++], NULL); + launched++; } + gc->pending = launched; tgc_notify_connecting(gc, ids, gc->handle_count); u_free(ids); @@ -259,6 +263,7 @@ int topo_group_connect_active_count(struct TOPO_GROUP* group) { void topo_group_connect_on_up(struct TOPO_GROUP* group, struct ETCP_CONN* conn) { if (!group || group->group_type != TOPO_GROUP_TYPE_CHAT || !group->channel_id[0] || !conn) return; uint64_t peer = conn->peer_node_id; + if (peer == group->instance->node_id) return; struct TOPO_GROUP_CONNECT* gc = group->connect; if (!gc) return; @@ -288,6 +293,7 @@ void topo_group_connect_on_up(struct TOPO_GROUP* group, struct ETCP_CONN* conn) void topo_group_connect_on_down(struct TOPO_GROUP* group, struct ETCP_CONN* conn) { if (!group || group->group_type != TOPO_GROUP_TYPE_CHAT || !group->channel_id[0] || !conn) return; uint64_t peer = conn->peer_node_id; + if (peer == group->instance->node_id) return; struct TOPO_GROUP_CONNECT* gc = group->connect; if (!gc) return; @@ -519,6 +525,7 @@ static void tgc_phase2_try_next(struct TOPO_GROUP_CONNECT* gc) { } if (gc->cursor < gc->candidate_count) { uint64_t nid = gc->candidate_ids[gc->cursor++]; + if (nid == gc->group->instance->node_id) continue; DEBUG_INFO(DEBUG_CATEGORY_BGP, "%s: Phase2 trying 0x%016llx (%d/%d) super_round=%d", TGC_ID, (unsigned long long)nid, gc->cursor, gc->candidate_count, gc->tried_super); if (node_conn_direct_open(gc->group->instance, nid, tgc_callback, gc, &gc->cur_handle, NULL) < 0) continue; @@ -553,6 +560,7 @@ static void tgc_phase3_try_next(struct TOPO_GROUP_CONNECT* gc) { } while (gc->cursor < gc->candidate_count) { uint64_t nid = gc->candidate_ids[gc->cursor++]; + if (nid == gc->group->instance->node_id) continue; DEBUG_INFO(DEBUG_CATEGORY_BGP, "%s: Phase3 trying 0x%016llx (%d/%d)", TGC_ID, (unsigned long long)nid, gc->cursor, gc->candidate_count); if (node_conn_direct_open(gc->group->instance, nid, tgc_callback, gc, &gc->cur_handle, NULL) < 0) continue; @@ -594,14 +602,18 @@ static void tgc_cycle_restart(struct TOPO_GROUP_CONNECT* gc) { return; } - gc->phase = TGC_PHASE_ONE; gc->pending = count; + gc->phase = TGC_PHASE_ONE; + int launched = 0; DEBUG_INFO(DEBUG_CATEGORY_BGP, "%s: cycle_restart Phase 1 launching %d connects ch=%s", TGC_ID, count, gc->group->channel_id); for (int i = 0; i < count && gc->handle_count < TGC_MAX_HANDLES; i++) { + if (ids[i] == gc->group->instance->node_id) { DEBUG_DEBUG(DEBUG_CATEGORY_BGP, "%s: Phase1 skip self 0x%016llx", TGC_ID, (unsigned long long)ids[i]); continue; } DEBUG_DEBUG(DEBUG_CATEGORY_BGP, "%s: Phase1 connect to 0x%016llx (%d/%d)", TGC_ID, (unsigned long long)ids[i], i + 1, count); node_conn_direct_open(gc->group->instance, ids[i], tgc_callback, gc, &gc->handles[gc->handle_count++], NULL); + launched++; } + gc->pending = launched; tgc_notify_connecting(gc, ids, gc->handle_count); u_free(ids);