From: Nick Mathewson Date: Thu, 8 May 2025 01:31:03 +0000 (-0400) Subject: Include message length in conflux_get_circ_bytes_allocation X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2cc6b0f18ca80e15596aef304d725769c2add7c2;p=thirdparty%2Ftor.git Include message length in conflux_get_circ_bytes_allocation --- diff --git a/src/core/or/conflux.c b/src/core/or/conflux.c index 140d15e7b7..96e218806a 100644 --- a/src/core/or/conflux.c +++ b/src/core/or/conflux.c @@ -172,7 +172,8 @@ uint64_t conflux_get_circ_bytes_allocation(const circuit_t *circ) { if (circ->conflux) { - return smartlist_len(circ->conflux->ooo_q) * sizeof(conflux_msg_t); + return smartlist_len(circ->conflux->ooo_q) * sizeof(void*) + + circ->conflux->ooo_q_alloc_cost; } return 0; } @@ -887,11 +888,13 @@ conflux_process_relay_msg(conflux_t *cfx, circuit_t *in_circ, * stack. This is simpler and less error prone but might show up in our * profile (maybe?). The Maze is serious. It needs to be respected. */ c_msg->msg = relay_msg_copy(msg); + size_t cost = conflux_msg_alloc_cost(c_msg); smartlist_pqueue_add(cfx->ooo_q, conflux_queue_cmp, offsetof(conflux_msg_t, heap_idx), c_msg); - total_ooo_q_bytes += conflux_msg_alloc_cost(c_msg); + total_ooo_q_bytes += cost; + cfx->ooo_q_alloc_cost += cost; /* This cell should not be processed yet, and the queue is not ready * to process because the next absolute seqnum has not yet arrived */ @@ -919,7 +922,11 @@ conflux_dequeue_relay_msg(conflux_t *cfx) if (top->seq == cfx->last_seq_delivered+1) { smartlist_pqueue_pop(cfx->ooo_q, conflux_queue_cmp, offsetof(conflux_msg_t, heap_idx)); - total_ooo_q_bytes -= conflux_msg_alloc_cost(top); + + size_t cost = conflux_msg_alloc_cost(top); + total_ooo_q_bytes -= cost; + cfx->ooo_q_alloc_cost -= cost; + cfx->last_seq_delivered++; return top; } else { diff --git a/src/core/or/conflux_st.h b/src/core/or/conflux_st.h index 61e38f8268..18961fb388 100644 --- a/src/core/or/conflux_st.h +++ b/src/core/or/conflux_st.h @@ -102,6 +102,12 @@ struct conflux_t { */ smartlist_t *ooo_q; + /** + * Approximate allocation cost of the bytes stored in ooo_q + * and the messages that it contains. + */ + size_t ooo_q_alloc_cost; + /** * Absolute sequence number of cells delivered to streams since start. * (ie: this is updated *after* dequeue from the ooo_q priority queue). */