]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Merge branch 'bug24700_032_01' into bug24700_033_01
authorDavid Goulet <dgoulet@torproject.org>
Thu, 1 Feb 2018 21:39:04 +0000 (16:39 -0500)
committerDavid Goulet <dgoulet@torproject.org>
Thu, 1 Feb 2018 21:39:04 +0000 (16:39 -0500)
1  2 
src/or/channel.c
src/or/scheduler.c
src/or/scheduler_kist.c

Simple merge
index 749df5a248438193d5108460fd1725523787b107,26f927fd8418107a5ad08af29570010e56bca9d1..931122f8d687f47f1605cf4bbbbdb2d20cbd455b
@@@ -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 {
index 424ef059068b5a79607eccc741eae51ce8e85c5c,d2878437c0be5b44c4098f705d895b7875ef6082..43831b72becfde88572074c0d7a70968806a9b1d
@@@ -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 */
  
    /* 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);