[tor/master] Merge branch 'bug24700_032_01' into bug24700_033_01

commit e1a40535eaac0cd7306770660da798a0ee247549 Merge: 5516d22a2 cb5654f30 Author: David Goulet <dgoulet@torproject.org> Date: Thu Feb 1 16:39:04 2018 -0500 Merge branch 'bug24700_032_01' into bug24700_033_01 changes/bug24700 | 4 ++++ src/or/channel.c | 3 +++ src/or/scheduler.c | 20 ++++++++++++-------- src/or/scheduler_kist.c | 14 ++++++++++---- 4 files changed, 29 insertions(+), 12 deletions(-) diff --cc src/or/scheduler.c index 749df5a24,26f927fd8..931122f8d --- a/src/or/scheduler.c +++ b/src/or/scheduler.c @@@ -559,11 -537,17 +559,13 @@@ scheduler_channel_has_waiting_cells,(ch * the other lists. It has waiting cells now, so it goes to * channels_pending. */ - chan->scheduler_state = SCHED_CHAN_PENDING; + scheduler_set_channel_state(chan, SCHED_CHAN_PENDING); - smartlist_pqueue_add(channels_pending, - scheduler_compare_channels, - offsetof(channel_t, sched_heap_idx), - chan); + if (!SCHED_BUG(chan->sched_heap_idx != -1, chan)) { + smartlist_pqueue_add(channels_pending, + scheduler_compare_channels, + offsetof(channel_t, sched_heap_idx), + chan); + } - log_debug(LD_SCHED, - "Channel " U64_FORMAT " at %p went from waiting_for_cells " - "to pending", - U64_PRINTF_ARG(chan->global_identifier), chan); /* If we made a channel pending, we potentially have scheduling work to * do. */ the_scheduler->schedule(); @@@ -678,11 -665,19 +680,13 @@@ scheduler_channel_wants_writes(channel_ /* * It can write now, so it goes to channels_pending. */ - smartlist_pqueue_add(channels_pending, - scheduler_compare_channels, - offsetof(channel_t, sched_heap_idx), - chan); - log_debug(LD_SCHED, "chan=%" PRIu64 " became pending", - chan->global_identifier); + scheduler_set_channel_state(chan, SCHED_CHAN_PENDING); + if (!SCHED_BUG(chan->sched_heap_idx != -1, chan)) { + smartlist_pqueue_add(channels_pending, + scheduler_compare_channels, + offsetof(channel_t, sched_heap_idx), + chan); + } - chan->scheduler_state = SCHED_CHAN_PENDING; - log_debug(LD_SCHED, - "Channel " U64_FORMAT " at %p went from waiting_to_write " - "to pending", - U64_PRINTF_ARG(chan->global_identifier), chan); /* We just made a channel pending, we have scheduling work to do. */ the_scheduler->schedule(); } else { diff --cc src/or/scheduler_kist.c index 424ef0590,d2878437c..43831b72b --- a/src/or/scheduler_kist.c +++ b/src/or/scheduler_kist.c @@@ -694,9 -703,11 +693,11 @@@ kist_scheduler_run(void /* Case 4: cells to send, and still open for writes */ - chan->scheduler_state = SCHED_CHAN_PENDING; + scheduler_set_channel_state(chan, SCHED_CHAN_PENDING); - smartlist_pqueue_add(cp, scheduler_compare_channels, - offsetof(channel_t, sched_heap_idx), chan); + if (!SCHED_BUG(chan->sched_heap_idx != -1, chan)) { + smartlist_pqueue_add(cp, scheduler_compare_channels, + offsetof(channel_t, sched_heap_idx), chan); + } } } /* End of main scheduling loop */ @@@ -714,10 -725,15 +715,15 @@@ /* Re-add any channels we need to */ if (to_readd) { SMARTLIST_FOREACH_BEGIN(to_readd, channel_t *, readd_chan) { - readd_chan->scheduler_state = SCHED_CHAN_PENDING; + scheduler_set_channel_state(readd_chan, SCHED_CHAN_PENDING); if (!smartlist_contains(cp, readd_chan)) { - smartlist_pqueue_add(cp, scheduler_compare_channels, + if (!SCHED_BUG(chan->sched_heap_idx != -1, chan)) { + /* XXXX Note that the check above is in theory redundant with + * the smartlist_contains check. But let's make sure we're + * not messing anything up, and leave them both for now. */ + smartlist_pqueue_add(cp, scheduler_compare_channels, offsetof(channel_t, sched_heap_idx), readd_chan); + } } } SMARTLIST_FOREACH_END(readd_chan); smartlist_free(to_readd);
participants (1)
-
nickm@torproject.org