conn_mgr: move etcp_router bind/unbind from per-group to instance level
svc_id=17 (ETCP_RT_ID_CONN_MGR) is a singleton resource — bind once at utun_instance_init, unbind once at utun_instance_destroy. Previously each conn_mgr (one per group) called bind/unbind separately, causing 'overwriting' and 'not bound' WARNs on every group init/shutdown. Handler dispatches by group_id from message — no need for per-group binding.
This commit is contained in:
1 parent
088879e760
commit
90e19b668f
3 files changed
+5
-6
No files matched your search
@@ -76,6 +76,7 @@ typedef void (*conn_mgr_cb_t)(struct CONN_MGR_HANDLE* h,
|
||||
|
||||
struct CONN_MGR* conn_mgr_init(struct TOPO_GROUP* group);
|
||||
void conn_mgr_destroy(struct CONN_MGR* mgr);
|
||||
void conn_mgr_router_recv_handler(struct ETCP_CONN* conn, struct ll_entry* entry);
|
||||
|
||||
/* ═══════ единая точка входа ═══════ */
|
||||
|
||||
|
||||
@@ -342,9 +342,6 @@ struct CONN_MGR* conn_mgr_init(struct TOPO_GROUP* group) {
|
||||
mgr->bg_ping_timer = uasync_set_timeout(mgr->instance->ua, CONN_MGR_BG_PING_INTERVAL_TB, mgr, cm_bg_ping_timer_cb, "conn_mgr_bg_ping");
|
||||
mgr->candidate_ping_timer = uasync_set_timeout(mgr->instance->ua, CONN_MGR_CANDIDATE_PING_TB, mgr, cm_candidate_ping_timer_cb, "conn_mgr_cand_ping");
|
||||
mgr->bg_ping_cycle_start_tb = get_time_tb(); mgr->initialized = 1;
|
||||
/* Первый conn_mgr биндит etcp_router (остальные перезаписывают тот же коллбэк — безвредно) */
|
||||
etcp_router_bind(mgr->instance, ETCP_RT_ID_CONN_MGR, conn_mgr_router_recv_handler);
|
||||
etcp_bind(mgr->instance, ETCP_RT_ID_CONN_MGR, conn_mgr_router_recv_handler);
|
||||
DEBUG_INFO(DEBUG_CATEGORY_GENERAL, "conn_mgr: initialized for group %016llx", (unsigned long long)group->group_id);
|
||||
return mgr;
|
||||
}
|
||||
@@ -353,9 +350,6 @@ void conn_mgr_destroy(struct CONN_MGR* mgr) {
|
||||
if (!mgr) return;
|
||||
if (mgr->bg_ping_timer) { uasync_cancel_timeout(mgr->instance->ua, mgr->bg_ping_timer); mgr->bg_ping_timer = NULL; }
|
||||
if (mgr->candidate_ping_timer) { uasync_cancel_timeout(mgr->instance->ua, mgr->candidate_ping_timer); mgr->candidate_ping_timer = NULL; }
|
||||
/* Отвязываемся от etcp_router (если ещё не отвязаны) */
|
||||
etcp_router_unbind(mgr->instance, ETCP_RT_ID_CONN_MGR);
|
||||
etcp_unbind(mgr->instance, ETCP_RT_ID_CONN_MGR);
|
||||
{ size_t ec = queue_entry_count(mgr->entries);
|
||||
struct ll_entry* e = mgr->entries->head;
|
||||
while (e) { struct ll_entry* next = e->next; struct CONN_MGR_ENTRY* entry = (struct CONN_MGR_ENTRY*)e; cm_entry_cleanup(entry); e = next; }
|
||||
|
||||
@@ -206,6 +206,8 @@ static int instance_init_common(struct UTUN_INSTANCE* instance, struct UASYNC* u
|
||||
DEBUG_ERROR(DEBUG_CATEGORY_BGP, "Failed to initialize BGP module");
|
||||
} else {
|
||||
DEBUG_INFO(DEBUG_CATEGORY_BGP, "BGP module initialized");
|
||||
etcp_router_bind(instance, ETCP_RT_ID_CONN_MGR, conn_mgr_router_recv_handler);
|
||||
etcp_bind(instance, ETCP_RT_ID_CONN_MGR, conn_mgr_router_recv_handler);
|
||||
struct TOPO_GROUP* g = topo_groups_get_default(instance->topo_groups);
|
||||
if (instance->rt && g && g->local_node) {
|
||||
topo_group_update_my_nodeinfo(instance, g);
|
||||
@@ -436,6 +438,8 @@ void utun_instance_destroy(struct UTUN_INSTANCE *instance) {
|
||||
// Cleanup BGP module BEFORE sockets (needs live conn_mgr for recovery cleanup)
|
||||
if (instance->topo_groups) {
|
||||
DEBUG_INFO(DEBUG_CATEGORY_BGP, "Destroying BGP module");
|
||||
etcp_router_unbind(instance, ETCP_RT_ID_CONN_MGR);
|
||||
etcp_unbind(instance, ETCP_RT_ID_CONN_MGR);
|
||||
topo_groups_destroy(instance);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user