Browse Source

control_server: fix infinite loop in router_conns aggregation — use read-only head->next traversal instead of get/put

chatgui
Evgeny 3 months ago
parent
commit
8427e18c98
  1. 6
      src/control_server.c

6
src/control_server.c

@ -1175,8 +1175,8 @@ static void send_metrics(struct control_server* server, struct control_client* c
/* Fill router congestion metrics — aggregate over all router_conns */
memset(&rsp->router, 0, sizeof(rsp->router));
if (instance->router_conns) {
struct ll_entry* re;
while ((re = queue_data_get(instance->router_conns)) != NULL) {
struct ll_entry* re = instance->router_conns->head;
while (re) {
struct ETCP_ROUTER_CONN* rc = (struct ETCP_ROUTER_CONN*)re;
rsp->router.total_inflight += (uint32_t)(rc->tx_seq - rc->tx_acked);
if (rc->send_q) rsp->router.total_send_q += (uint32_t)queue_entry_count(rc->send_q);
@ -1190,7 +1190,7 @@ static void send_metrics(struct control_server* server, struct control_client* c
rsp->router.oob_dropped += rc->c_oob_dropped;
rsp->router.stale_ack += rc->c_stale_ack;
rsp->router.sign_fail += rc->c_sign_fail;
queue_data_put_with_index(instance->router_conns, re);
re = re->next;
}
rsp->router.total_conns = (uint32_t)queue_entry_count(instance->router_conns);
}

Loading…
Cancel
Save