tor

The Tor anonymity network
git clone https://git.dasho.dev/tor.git
Log | Files | Refs | README | LICENSE

commit 2cc6b0f18ca80e15596aef304d725769c2add7c2
parent a0aa6d969c4c86971ac65bacb89749a9ce15a105
Author: Nick Mathewson <nickm@torproject.org>
Date:   Wed,  7 May 2025 21:31:03 -0400

Include message length in conflux_get_circ_bytes_allocation

Diffstat:
Msrc/core/or/conflux.c | 13++++++++++---
Msrc/core/or/conflux_st.h | 6++++++
2 files changed, 16 insertions(+), 3 deletions(-)

diff --git 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 @@ -103,6 +103,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). */ uint64_t last_seq_delivered;