[tor] branch main updated: circ: Add function to learn if queue is full

This is an automated email from the git hooks/post-receive script. dgoulet pushed a commit to branch main in repository tor. The following commit(s) were added to refs/heads/main by this push: new cfdc9f9d29 circ: Add function to learn if queue is full cfdc9f9d29 is described below commit cfdc9f9d29fb369a139f4a3a35a829ebe66807bb Author: David Goulet <dgoulet@torproject.org> AuthorDate: Wed Dec 14 10:19:14 2022 -0500 circ: Add function to learn if queue is full Related to #40731 Signed-off-by: David Goulet <dgoulet@torproject.org> --- src/core/or/circuitlist.c | 24 ++++++++++++++++++++++++ src/core/or/circuitlist.h | 2 ++ 2 files changed, 26 insertions(+) diff --git a/src/core/or/circuitlist.c b/src/core/or/circuitlist.c index 50dc2ee338..cea3a2136f 100644 --- a/src/core/or/circuitlist.c +++ b/src/core/or/circuitlist.c @@ -2831,3 +2831,27 @@ assert_circuit_ok,(const circuit_t *c)) tor_assert(!or_circ || !or_circ->rend_splice); } } + +/** Return true iff the circuit queue for the given direction is full that is + * above the high watermark. */ +bool +circuit_is_queue_full(const circuit_t *circ, cell_direction_t direction) +{ + int queue_size; + + tor_assert(circ); + + /* Gather objects we need based on cell direction. */ + if (direction == CELL_DIRECTION_OUT) { + /* Outbound. */ + queue_size = circ->n_chan_cells.n; + } else { + /* Inbound. */ + queue_size = CONST_TO_OR_CIRCUIT(circ)->p_chan_cells.n; + } + + /* Then check if our cell queue has reached its high watermark as in its + * upper limit. This is so we avoid too much memory pressure by queuing a + * large amount of cells. */ + return queue_size >= cell_queue_highwatermark(); +} diff --git a/src/core/or/circuitlist.h b/src/core/or/circuitlist.h index 541a708de2..49ded11f12 100644 --- a/src/core/or/circuitlist.h +++ b/src/core/or/circuitlist.h @@ -247,6 +247,8 @@ MOCK_DECL(void, channel_note_destroy_not_pending, smartlist_t *circuit_find_circuits_to_upgrade_from_guard_wait(void); +bool circuit_is_queue_full(const circuit_t *circ, cell_direction_t direction); + /* Declare the handle helpers */ HANDLE_DECL(circuit, circuit_t, ) #define circuit_handle_free(h) \ -- To stop receiving notification emails like this one, please contact the administrator of this repository.
participants (1)
-
gitolite role