diff options
author | David Goulet <dgoulet@torproject.org> | 2017-11-20 15:53:25 -0500 |
---|---|---|
committer | David Goulet <dgoulet@torproject.org> | 2017-11-22 09:41:10 -0500 |
commit | d165f0fd30bc9823152dad6769afab0afae2ea6d (patch) | |
tree | b96427f4a3cb031eab1e5c2c993972822c5502b7 /src/or/relay.c | |
parent | bf242ebe6c7e13cf30fedc006e8d25597f9e602d (diff) | |
download | tor-d165f0fd30bc9823152dad6769afab0afae2ea6d.tar.gz tor-d165f0fd30bc9823152dad6769afab0afae2ea6d.zip |
relay: Improve comment in append_cell_to_circuit_queue()
This function is part of the tor fast path so this commit adds more
documentation to it as it is critical.
Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/or/relay.c')
-rw-r--r-- | src/or/relay.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/or/relay.c b/src/or/relay.c index eb9d030802..d6c103c146 100644 --- a/src/or/relay.c +++ b/src/or/relay.c @@ -2859,7 +2859,12 @@ channel_flush_from_first_active_circuit, (channel_t *chan, int max)) } /** Add <b>cell</b> to the queue of <b>circ</b> writing to <b>chan</b> - * transmitting in <b>direction</b>. */ + * transmitting in <b>direction</b>. + * + * The given <b>cell</b> is copied over the circuit queue so the caller must + * cleanup the memory. + * + * This function is part of the fast path. */ void append_cell_to_circuit_queue(circuit_t *circ, channel_t *chan, cell_t *cell, cell_direction_t direction, @@ -2882,11 +2887,14 @@ append_cell_to_circuit_queue(circuit_t *circ, channel_t *chan, streams_blocked = circ->streams_blocked_on_p_chan; } + /* Very important that we copy to the circuit queue because all calls to + * this function use the stack for the cell memory. */ cell_queue_append_packed_copy(circ, queue, exitward, cell, chan->wide_circ_ids, 1); + /* Check and run the OOM if needed. */ if (PREDICT_UNLIKELY(cell_queues_check_size())) { - /* We ran the OOM handler */ + /* We ran the OOM handler which might have closed this circuit. */ if (circ->marked_for_close) return; } |