Browse Source

fix: merkle_sync.c linked-list -> queue lookup, upgrade debug logs to INFO

- merkle_sync.c ms_find_conn_for_node: replace c=c->next with queue_find_data_by_index
- chat_sync.c cs_find_conn_for_node, cs_on_conn_up: DEBUG_DEBUG -> DEBUG_INFO
- etcp.c queue_set_ready: DEBUG_DEBUG -> DEBUG_INFO
topo_upd
Evgeny 3 months ago
parent
commit
d161782b46
  1. 4
      src/etcp.c
  2. 8
      tools/chatgui/transport/chat_sync.c
  3. 9
      tools/chatgui/transport/merkle_sync.c

4
src/etcp.c

@ -581,7 +581,7 @@ void etcp_conn_queue_set_ready(struct ETCP_CONN* conn) {
if (!conn || conn->state != 0) return; if (!conn || conn->state != 0) return;
// Reindex: remove old entry (key=0), add new entry with real peer_node_id // Reindex: remove old entry (key=0), add new entry with real peer_node_id
DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, "[%s] queue_set_ready: removing old entry=%p key=0 -> new key=0x%llx", DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "[%s] queue_set_ready: removing old entry=%p key=0 -> new key=0x%llx",
conn->log_name, (void*)conn->conn_queue_entry, (unsigned long long)conn->peer_node_id); conn->log_name, (void*)conn->conn_queue_entry, (unsigned long long)conn->peer_node_id);
if (conn->conn_queue && conn->conn_queue_entry) { if (conn->conn_queue && conn->conn_queue_entry) {
queue_remove_data(conn->conn_queue, conn->conn_queue_entry); queue_remove_data(conn->conn_queue, conn->conn_queue_entry);
@ -597,7 +597,7 @@ void etcp_conn_queue_set_ready(struct ETCP_CONN* conn) {
conn->conn_queue = conn->instance->connections; conn->conn_queue = conn->instance->connections;
conn->state = 1; conn->state = 1;
queue_data_put_with_index(conn->instance->connections, qe); queue_data_put_with_index(conn->instance->connections, qe);
DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, "[%s] queue_set_ready: new entry=%p put in queue, count=%d", DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "[%s] queue_set_ready: new entry=%p put in queue, count=%d",
conn->log_name, (void*)qe, queue_entry_count(conn->instance->connections)); conn->log_name, (void*)qe, queue_entry_count(conn->instance->connections));
DEBUG_INFO(DEBUG_CATEGORY_ETCP, "[%s] moved to ready queue, state=%d peer_node_id=0x%llx", DEBUG_INFO(DEBUG_CATEGORY_ETCP, "[%s] moved to ready queue, state=%d peer_node_id=0x%llx",

8
tools/chatgui/transport/chat_sync.c

@ -434,16 +434,16 @@ static void cs_join_timeout_cb(void* arg) {
/* ── helper: find active ETCP_CONN for node ── */ /* ── helper: find active ETCP_CONN for node ── */
static struct ETCP_CONN* cs_find_conn_for_node(struct UTUN_INSTANCE* inst, uint64_t node_id) { static struct ETCP_CONN* cs_find_conn_for_node(struct UTUN_INSTANCE* inst, uint64_t node_id) {
if (!inst->connections) { DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, "%s: find_conn connections=NULL", CS_ID); return NULL; } if (!inst->connections) { DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "%s: find_conn connections=NULL", CS_ID); return NULL; }
struct ll_entry* e = queue_find_data_by_index(inst->connections, (const uint8_t*)&node_id); struct ll_entry* e = queue_find_data_by_index(inst->connections, (const uint8_t*)&node_id);
if (e) { if (e) {
struct conn_queue_entry* ce = (struct conn_queue_entry*)e->data; struct conn_queue_entry* ce = (struct conn_queue_entry*)e->data;
DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, "%s: find_conn node=%016llx found=%p initialized=%d links_up=%d state=%d", DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "%s: find_conn node=%016llx found=%p initialized=%d links_up=%d state=%d",
CS_ID, (unsigned long long)node_id, (void*)ce->conn, ce->conn->initialized, ce->conn->links_up, ce->conn->state); CS_ID, (unsigned long long)node_id, (void*)ce->conn, ce->conn->initialized, ce->conn->links_up, ce->conn->state);
if (ce->conn->initialized && ce->conn->links_up) return ce->conn; if (ce->conn->initialized && ce->conn->links_up) return ce->conn;
return NULL; return NULL;
} }
DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, "%s: find_conn node=%016llx NOT FOUND in queue (head=%p count=%d)", DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "%s: find_conn node=%016llx NOT FOUND in queue (head=%p count=%d)",
CS_ID, (unsigned long long)node_id, (void*)inst->connections->head, queue_entry_count(inst->connections)); CS_ID, (unsigned long long)node_id, (void*)inst->connections->head, queue_entry_count(inst->connections));
return NULL; return NULL;
} }
@ -492,7 +492,7 @@ static void cs_on_conn_up(struct ETCP_CONN* conn, void* arg) {
if (!conn || !g_cs) return; if (!conn || !g_cs) return;
uint64_t peer = conn->peer_node_id; uint64_t peer = conn->peer_node_id;
if (peer == 0 || peer == g_cs->inst->node_id) return; if (peer == 0 || peer == g_cs->inst->node_id) return;
if (!conn->initialized) { DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, "%s: conn_up SKIP — not initialized peer=%016llx", CS_ID, (unsigned long long)peer); return; } if (!conn->initialized) { DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "%s: conn_up SKIP — not initialized peer=%016llx", CS_ID, (unsigned long long)peer); return; }
if (g_cs->pending_invite_ch_id != 0 && !g_cs->info_req_timer) { if (g_cs->pending_invite_ch_id != 0 && !g_cs->info_req_timer) {
DEBUG_INFO(DEBUG_CATEGORY_CONNECTIVITY, "%s: conn_up invite path peer=%016llx ch=%llu", DEBUG_INFO(DEBUG_CATEGORY_CONNECTIVITY, "%s: conn_up invite path peer=%016llx ch=%llu",

9
tools/chatgui/transport/merkle_sync.c

@ -174,10 +174,11 @@ static int _get_level_hashes(struct merkle_sync* ms, const char* ns,
/* ── Send helpers ── */ /* ── Send helpers ── */
static struct ETCP_CONN* ms_find_conn_for_node(struct UTUN_INSTANCE* inst, uint64_t node_id) { static struct ETCP_CONN* ms_find_conn_for_node(struct UTUN_INSTANCE* inst, uint64_t node_id) {
struct ETCP_CONN* c = inst->connections; if (!inst->connections) return NULL;
while (c) { struct ll_entry* e = queue_find_data_by_index(inst->connections, (const uint8_t*)&node_id);
if (c->peer_node_id == node_id && c->initialized && c->links_up) return c; if (e) {
c = c->next; struct conn_queue_entry* ce = (struct conn_queue_entry*)e->data;
if (ce->conn->initialized && ce->conn->links_up) return ce->conn;
} }
return NULL; return NULL;
} }

Loading…
Cancel
Save