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
This commit is contained in:
1 parent
188ffdc0c6
commit
faa86d11dd
3 files changed
+11
-10
No files matched your search
+2
-2
@@ -581,7 +581,7 @@ void etcp_conn_queue_set_ready(struct ETCP_CONN* conn) {
|
||||
if (!conn || conn->state != 0) return;
|
||||
|
||||
// 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);
|
||||
if (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->state = 1;
|
||||
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));
|
||||
|
||||
DEBUG_INFO(DEBUG_CATEGORY_ETCP, "[%s] moved to ready queue, state=%d peer_node_id=0x%llx",
|
||||
|
||||
@@ -434,16 +434,16 @@ static void cs_join_timeout_cb(void* arg) {
|
||||
/* ── helper: find active ETCP_CONN for node ── */
|
||||
|
||||
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);
|
||||
if (e) {
|
||||
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);
|
||||
if (ce->conn->initialized && ce->conn->links_up) return ce->conn;
|
||||
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));
|
||||
return NULL;
|
||||
}
|
||||
@@ -492,7 +492,7 @@ static void cs_on_conn_up(struct ETCP_CONN* conn, void* arg) {
|
||||
if (!conn || !g_cs) return;
|
||||
uint64_t peer = conn->peer_node_id;
|
||||
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) {
|
||||
DEBUG_INFO(DEBUG_CATEGORY_CONNECTIVITY, "%s: conn_up invite path peer=%016llx ch=%llu",
|
||||
|
||||
@@ -174,10 +174,11 @@ static int _get_level_hashes(struct merkle_sync* ms, const char* ns,
|
||||
/* ── Send helpers ── */
|
||||
|
||||
static struct ETCP_CONN* ms_find_conn_for_node(struct UTUN_INSTANCE* inst, uint64_t node_id) {
|
||||
struct ETCP_CONN* c = inst->connections;
|
||||
while (c) {
|
||||
if (c->peer_node_id == node_id && c->initialized && c->links_up) return c;
|
||||
c = c->next;
|
||||
if (!inst->connections) return NULL;
|
||||
struct ll_entry* e = queue_find_data_by_index(inst->connections, (const uint8_t*)&node_id);
|
||||
if (e) {
|
||||
struct conn_queue_entry* ce = (struct conn_queue_entry*)e->data;
|
||||
if (ce->conn->initialized && ce->conn->links_up) return ce->conn;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user