diff options
author | David Goulet <dgoulet@torproject.org> | 2018-02-02 08:48:34 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2018-02-02 12:03:27 -0500 |
commit | 005e228f80f0bd241d01c106f87e6bfe6dda6127 (patch) | |
tree | dc2c4a5e6b5fc7cd38c4e76574211fcdd70fcf55 /src/test/test_scheduler.c | |
parent | 77634795b0258f04a31a51d827d45eab40557f65 (diff) | |
download | tor-005e228f80f0bd241d01c106f87e6bfe6dda6127.tar.gz tor-005e228f80f0bd241d01c106f87e6bfe6dda6127.zip |
sched: When releasing a channel, do not BUG() if absent from the pending list
The current code flow makes it that we can release a channel in a PENDING
state but not in the pending list. This happens while the channel is being
processed in the scheduler loop.
Fixes #25125
Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/test/test_scheduler.c')
-rw-r--r-- | src/test/test_scheduler.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/test/test_scheduler.c b/src/test/test_scheduler.c index 1f014c4f6a..724a6b56b2 100644 --- a/src/test/test_scheduler.c +++ b/src/test/test_scheduler.c @@ -502,6 +502,18 @@ perform_channel_state_tests(int KISTSchedRunInterval, int sched_type) scheduler_touch_channel(ch1); tt_assert(scheduler_compare_channels_mock_ctr > old_count); + /* Release the ch2 and then do it another time to make sure it doesn't blow + * up and we are still in a quiescent state. */ + scheduler_release_channel(ch2); + tt_int_op(ch2->scheduler_state, OP_EQ, SCHED_CHAN_IDLE); + tt_int_op(smartlist_len(channels_pending), OP_EQ, 1); + /* Cheat a bit so make the release more confused but also will tells us if + * the release did put the channel in the right state. */ + ch2->scheduler_state = SCHED_CHAN_PENDING; + scheduler_release_channel(ch2); + tt_int_op(ch2->scheduler_state, OP_EQ, SCHED_CHAN_IDLE); + tt_int_op(smartlist_len(channels_pending), OP_EQ, 1); + /* Close */ channel_mark_for_close(ch1); tt_int_op(ch1->state, OP_EQ, CHANNEL_STATE_CLOSING); |