aboutsummaryrefslogtreecommitdiff
path: root/src/test/test_channel.c
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@torproject.org>2017-12-07 15:41:09 -0500
committerNick Mathewson <nickm@torproject.org>2017-12-08 14:43:27 -0500
commit6120efd771928fc958b552b9f5c3e09d949e92fe (patch)
tree1ce64d9813387af6384f35d71224baf3a32252c0 /src/test/test_channel.c
parent428ee55e5187a57b8bbc171c8b62da08209a7954 (diff)
downloadtor-6120efd771928fc958b552b9f5c3e09d949e92fe.tar.gz
tor-6120efd771928fc958b552b9f5c3e09d949e92fe.zip
chan: Do not re-queue after a fail cell write
Couple things happen in this commit. First, we do not re-queue a cell back in the circuit queue if the write packed cell failed. Currently, it is close to impossible to have it failed but just in case, the channel is mark as closed and we move on. The second thing is that the channel_write_packed_cell() always took ownership of the cell whatever the outcome. This means, on success or failure, it needs to free it. It turns out that that we were using the wrong free function in one case and not freeing it in an other possible code path. So, this commit makes sure we only free it in one place that is at the very end of channel_write_packed_cell() which is the top layer of the channel abstraction. This makes also channel_tls_write_packed_cell_method() return a negative value on error. Two unit tests had to be fixed (quite trivial) due to a double free of the packed cell in the test since now we do free it in all cases correctly. Part of #23709 Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/test/test_channel.c')
-rw-r--r--src/test/test_channel.c2
1 files changed, 0 insertions, 2 deletions
diff --git a/src/test/test_channel.c b/src/test/test_channel.c
index 88a13862bd..c3b99d87ac 100644
--- a/src/test/test_channel.c
+++ b/src/test/test_channel.c
@@ -199,7 +199,6 @@ chan_test_write_packed_cell(channel_t *ch,
if (test_chan_accept_cells) {
/* Free the cell and bump the counter */
- packed_cell_free(packed_cell);
++test_cells_written;
rv = 1;
}
@@ -846,7 +845,6 @@ test_channel_lifecycle(void *arg)
done:
free_fake_channel(ch1);
free_fake_channel(ch2);
- tor_free(p_cell);
UNMOCK(scheduler_channel_doesnt_want_writes);
UNMOCK(scheduler_release_channel);