Browse Source

auto_connect: diagnostic logging for early FAIL paths in chat_core_connect_auto

- chat_core.c: add DEBUG_INFO before each synchronous cb(FAIL) — pinpoints exact failure reason
- chat_sync.c: add log in ac_fill when ca_state=NULL after chat_core_connect_auto call
topo_upd
Evgeny 3 months ago
parent
commit
9245a30fa5
  1. 24
      tools/chatgui/transport/chat_core.c
  2. 1
      tools/chatgui/transport/chat_sync.c

24
tools/chatgui/transport/chat_core.c

@ -727,14 +727,18 @@ void chat_core_connect_auto(uint64_t node_id,
void (*cb)(int result, uint64_t node_id, void* arg),
void* arg,
void** out_state) {
if (!g_cc.initialized || !g_cc.inst || !cb) return;
if (!g_cc.initialized || !g_cc.inst || !cb) {
DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "%s: auto_connect FAIL (not initialized) node=0x%016llx init=%d inst=%p cb=%p",
CC_ID, (unsigned long long)node_id, g_cc.initialized, (void*)g_cc.inst, (void*)cb);
return;
}
if (out_state) *out_state = NULL;
struct ETCP_SOCKET* best_socket = g_cc.inst->etcp_sockets;
while (best_socket && best_socket->local_addr.ss_family != AF_INET) best_socket = best_socket->next;
if (!best_socket) {
DEBUG_ERROR(DEBUG_CATEGORY_CONNECTIVITY, "%s: auto_connect no AF_INET socket for node 0x%016llx",
CC_ID, (unsigned long long)node_id);
DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "%s: auto_connect FAIL (no AF_INET socket) node=0x%016llx sockets=%p",
CC_ID, (unsigned long long)node_id, (void*)g_cc.inst->etcp_sockets);
cb(CC_ERR_INTERNAL, node_id, arg);
return;
}
@ -753,8 +757,8 @@ void chat_core_connect_auto(uint64_t node_id,
sqlite3_finalize(st);
}
if (pubkey[0] == 0 && pubkey[1] == 0) {
DEBUG_ERROR(DEBUG_CATEGORY_CONNECTIVITY, "%s: auto_connect no pubkey for node 0x%016llx",
CC_ID, (unsigned long long)node_id);
DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "%s: auto_connect FAIL (no pubkey in DB) node=0x%016llx",
CC_ID, (unsigned long long)node_id);
cb(CC_ERR_NOT_FOUND, node_id, arg);
return;
}
@ -787,13 +791,14 @@ void chat_core_connect_auto(uint64_t node_id,
}
addr_count = uniq; }
if (addr_count == 0) {
DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, "%s: auto_connect no IPv4 addrs yet for node 0x%016llx (BGP not synced?)", CC_ID, (unsigned long long)node_id);
DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "%s: auto_connect FAIL (no IPv4 addrs in DB) node=0x%016llx (BGP not synced?)",
CC_ID, (unsigned long long)node_id);
cb(CC_ERR_NO_ADDRESSES, node_id, arg);
return;
}
struct ca_state* pst = u_calloc(1, sizeof(struct ca_state));
if (!pst) { cb(CC_ERR_INTERNAL, node_id, arg); return; }
if (!pst) { DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "%s: auto_connect FAIL (alloc ca_state) node=0x%016llx", CC_ID, (unsigned long long)node_id); cb(CC_ERR_INTERNAL, node_id, arg); return; }
pst->inst = g_cc.inst;
pst->addr_count = addr_count;
pst->pending_count = addr_count;
@ -804,7 +809,7 @@ void chat_core_connect_auto(uint64_t node_id,
pst->conns = u_calloc(addr_count, sizeof(struct ETCP_CONN*));
pst->timers = u_calloc(addr_count, sizeof(void*));
pst->ctxs = u_calloc(addr_count, sizeof(struct ca_ctx*));
if (!pst->conns || !pst->timers || !pst->ctxs) { ca_cleanup(pst); cb(CC_ERR_INTERNAL, node_id, arg); return; }
if (!pst->conns || !pst->timers || !pst->ctxs) { DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "%s: auto_connect FAIL (alloc arrays) node=0x%016llx", CC_ID, (unsigned long long)node_id); ca_cleanup(pst); cb(CC_ERR_INTERNAL, node_id, arg); return; }
for (int i = 0; i < addr_count; i++) {
struct sockaddr_in sin;
@ -847,7 +852,8 @@ void chat_core_connect_auto(uint64_t node_id,
if (out_state) *out_state = pst;
if (pst->pending_count <= 0 && !pst->delivered) {
DEBUG_ERROR(DEBUG_CATEGORY_CONNECTIVITY, "%s: auto_connect all %d attempts failed to start", CC_ID, addr_count);
DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "%s: auto_connect FAIL (all %d attempts failed to start) node=0x%016llx",
CC_ID, addr_count, (unsigned long long)node_id);
if (out_state) *out_state = NULL;
cb(CC_ERR_UNREACHABLE, node_id, arg);
ca_cleanup(pst);

1
tools/chatgui/transport/chat_sync.c

@ -180,6 +180,7 @@ static void ac_fill(struct auto_connect* ac) {
f->created_tb = get_time_tb();
chat_core_connect_auto(nid, ac_result_cb, f, &f->ca_state);
if (!f->ca_state) {
DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "%s: flight to 0x%016llx FAIL (ca_state=NULL, sync fail in chat_core_connect_auto)", AC_ID, (unsigned long long)nid);
f->node_id = 0; f->created_tb = 0;
continue;
}

Loading…
Cancel
Save