[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/master] sched: rename scheduler to the_scheduler



commit 8ccb2c106afa29f5c44101574775f01cd435adbf
Author: Matt Traudt <sirmatt@xxxxxxx>
Date:   Wed Sep 13 12:54:49 2017 -0400

    sched: rename scheduler to the_scheduler
---
 src/or/scheduler.c        | 48 +++++++++++++++++++++++------------------------
 src/or/scheduler.h        |  2 +-
 src/test/test_scheduler.c | 32 +++++++++++++++----------------
 3 files changed, 41 insertions(+), 41 deletions(-)

diff --git a/src/or/scheduler.c b/src/or/scheduler.c
index b4e1aac92..cb93f93c6 100644
--- a/src/or/scheduler.c
+++ b/src/or/scheduler.c
@@ -148,7 +148,7 @@
  * outside the scheduling system)
  *****************************************************************************/
 
-STATIC scheduler_t *scheduler;
+STATIC scheduler_t *the_scheduler;
 
 /*
  * We keep a list of channels that are pending - i.e, have cells to write
@@ -187,12 +187,12 @@ scheduler_evt_callback(evutil_socket_t fd, short events, void *arg)
   tor_assert(run_sched_ev);
 
   /* Run the scheduler. This is a mandatory function. */
-  tor_assert(scheduler->run);
-  scheduler->run();
+  tor_assert(the_scheduler->run);
+  the_scheduler->run();
 
   /* Schedule itself back in if it has more work. */
-  tor_assert(scheduler->schedule);
-  scheduler->schedule();
+  tor_assert(the_scheduler->schedule);
+  the_scheduler->schedule();
 }
 
 /*****************************************************************************
@@ -275,16 +275,16 @@ set_scheduler(void)
   int have_kist = 0;
 
   /* Switch, if needed */
-  scheduler_t *old_scheduler = scheduler;
+  scheduler_t *old_scheduler = the_scheduler;
   if (scheduler_should_use_kist()) {
-    scheduler = get_kist_scheduler();
+    the_scheduler = get_kist_scheduler();
     have_kist = 1;
   } else {
-    scheduler = get_vanilla_scheduler();
+    the_scheduler = get_vanilla_scheduler();
   }
-  tor_assert(scheduler);
+  tor_assert(the_scheduler);
 
-  if (old_scheduler != scheduler) {
+  if (old_scheduler != the_scheduler) {
     /* Allow the old scheduler to clean up, if needed. */
     if (old_scheduler && old_scheduler->free_all) {
       old_scheduler->free_all();
@@ -293,8 +293,8 @@ set_scheduler(void)
      * we've allocated so we can do an easy switch back. */
 
     /* Initialize the new scheduler. */
-    if (scheduler->init) {
-      scheduler->init();
+    if (the_scheduler->init) {
+      the_scheduler->init();
     }
     log_notice(LD_CONFIG, "Using the %s scheduler.",
                have_kist ? "KIST" : "vanilla");
@@ -312,8 +312,8 @@ scheduler_conf_changed(void)
   set_scheduler();
 
   /* Then tell the (possibly new) scheduler that we have new options. */
-  if (scheduler->on_new_options) {
-    scheduler->on_new_options();
+  if (the_scheduler->on_new_options) {
+    the_scheduler->on_new_options();
   }
 }
 
@@ -325,8 +325,8 @@ scheduler_notify_networkstatus_changed(const networkstatus_t *old_c,
                                        const networkstatus_t *new_c)
 {
   /* Then tell the (possibly new) scheduler that we have a new consensus */
-  if (scheduler->on_new_consensus) {
-    scheduler->on_new_consensus(old_c, new_c);
+  if (the_scheduler->on_new_consensus) {
+    the_scheduler->on_new_consensus(old_c, new_c);
   }
   /* Maybe the consensus param made us change the scheduler. */
   set_scheduler();
@@ -356,11 +356,11 @@ scheduler_free_all(void)
     channels_pending = NULL;
   }
 
-  if (scheduler && scheduler->free_all) {
-    scheduler->free_all();
+  if (the_scheduler && the_scheduler->free_all) {
+    the_scheduler->free_all();
   }
-  tor_free(scheduler);
-  scheduler = NULL;
+  tor_free(the_scheduler);
+  the_scheduler = NULL;
 }
 
 /** Mark a channel as no longer ready to accept writes */
@@ -429,7 +429,7 @@ scheduler_channel_has_waiting_cells,(channel_t *chan))
               U64_PRINTF_ARG(chan->global_identifier), chan);
     /* If we made a channel pending, we potentially have scheduling work to
      * do. */
-    scheduler->schedule();
+    the_scheduler->schedule();
   } else {
     /*
      * It's not in waiting_for_cells, so it can't become pending; it's
@@ -487,8 +487,8 @@ scheduler_release_channel,(channel_t *chan))
                               offsetof(channel_t, sched_heap_idx),
                               chan);
     }
-    if (scheduler->on_channel_free) {
-      scheduler->on_channel_free(chan);
+    if (the_scheduler->on_channel_free) {
+      the_scheduler->on_channel_free(chan);
     }
   }
 
@@ -520,7 +520,7 @@ scheduler_channel_wants_writes(channel_t *chan)
               "to pending",
               U64_PRINTF_ARG(chan->global_identifier), chan);
     /* We just made a channel pending, we have scheduling work to do. */
-    scheduler->schedule();
+    the_scheduler->schedule();
   } else {
     /*
      * It's not in SCHED_CHAN_WAITING_TO_WRITE, so it can't become pending;
diff --git a/src/or/scheduler.h b/src/or/scheduler.h
index 0d8235273..68de5cf66 100644
--- a/src/or/scheduler.h
+++ b/src/or/scheduler.h
@@ -138,7 +138,7 @@ MOCK_DECL(int, scheduler_compare_channels,
 #ifdef TOR_UNIT_TESTS
 extern smartlist_t *channels_pending;
 extern struct event *run_sched_ev;
-extern scheduler_t *scheduler;
+extern scheduler_t *the_scheduler;
 void scheduler_touch_channel(channel_t *chan);
 #endif /* TOR_UNIT_TESTS */
 
diff --git a/src/test/test_scheduler.c b/src/test/test_scheduler.c
index 3ab8ed2bf..680648344 100644
--- a/src/test/test_scheduler.c
+++ b/src/test/test_scheduler.c
@@ -408,7 +408,7 @@ perform_channel_state_tests(int KISTSchedRunInterval)
    * Disable scheduler_run so we can just check the state transitions
    * without having to make everything it might call work too.
    */
-  scheduler->run = scheduler_run_noop_mock;
+  the_scheduler->run = scheduler_run_noop_mock;
 
   tt_int_op(smartlist_len(channels_pending), OP_EQ, 0);
 
@@ -616,8 +616,8 @@ test_scheduler_loop_vanilla(void *arg)
    * Disable scheduler_run so we can just check the state transitions
    * without having to make everything it might call work too.
    */
-  run_func_ptr = scheduler->run;
-  scheduler->run = scheduler_run_noop_mock;
+  run_func_ptr = the_scheduler->run;
+  the_scheduler->run = scheduler_run_noop_mock;
 
   tt_int_op(smartlist_len(channels_pending), OP_EQ, 0);
 
@@ -807,19 +807,19 @@ test_scheduler_loop_kist(void *arg)
   scheduler_channel_wants_writes(ch2);
   channel_flush_some_cells_mock_set(ch2, 5);
 
-  scheduler->run();
+  the_scheduler->run();
 
   scheduler_channel_has_waiting_cells(ch1);
   channel_flush_some_cells_mock_set(ch1, 5);
 
-  scheduler->run();
+  the_scheduler->run();
 
   scheduler_channel_has_waiting_cells(ch1);
   channel_flush_some_cells_mock_set(ch1, 5);
   scheduler_channel_has_waiting_cells(ch2);
   channel_flush_some_cells_mock_set(ch2, 5);
 
-  scheduler->run();
+  the_scheduler->run();
 
   channel_flush_some_cells_mock_free_all();
   tt_int_op(1,==,1);
@@ -865,7 +865,7 @@ test_scheduler_initfree(void *arg)
   tt_ptr_op(run_sched_ev, !=, NULL);
   /* We have specified nothing in the torrc and there's no consensus so the
    * KIST scheduler is what should be in use */
-  tt_ptr_op(scheduler, ==, get_kist_scheduler());
+  tt_ptr_op(the_scheduler, ==, get_kist_scheduler());
   tt_int_op(sched_run_interval, ==, 10);
 
   scheduler_free_all();
@@ -954,35 +954,35 @@ test_scheduler_ns_changed(void *arg)
   MOCK(get_options, mock_get_options);
   clear_options();
 
-  tt_ptr_op(scheduler, ==, NULL);
+  tt_ptr_op(the_scheduler, ==, NULL);
 
   /* Change from vanilla to kist via consensus */
-  scheduler = get_vanilla_scheduler();
+  the_scheduler = get_vanilla_scheduler();
   MOCK(networkstatus_get_param, mock_kist_networkstatus_get_param);
   scheduler_notify_networkstatus_changed(NULL, NULL);
   UNMOCK(networkstatus_get_param);
-  tt_ptr_op(scheduler, ==, get_kist_scheduler());
+  tt_ptr_op(the_scheduler, ==, get_kist_scheduler());
 
   /* Change from kist to vanilla via consensus */
-  scheduler = get_kist_scheduler();
+  the_scheduler = get_kist_scheduler();
   MOCK(networkstatus_get_param, mock_vanilla_networkstatus_get_param);
   scheduler_notify_networkstatus_changed(NULL, NULL);
   UNMOCK(networkstatus_get_param);
-  tt_ptr_op(scheduler, ==, get_vanilla_scheduler());
+  tt_ptr_op(the_scheduler, ==, get_vanilla_scheduler());
 
   /* Doesn't change when using KIST */
-  scheduler = get_kist_scheduler();
+  the_scheduler = get_kist_scheduler();
   MOCK(networkstatus_get_param, mock_kist_networkstatus_get_param);
   scheduler_notify_networkstatus_changed(NULL, NULL);
   UNMOCK(networkstatus_get_param);
-  tt_ptr_op(scheduler, ==, get_kist_scheduler());
+  tt_ptr_op(the_scheduler, ==, get_kist_scheduler());
 
   /* Doesn't change when using vanilla */
-  scheduler = get_vanilla_scheduler();
+  the_scheduler = get_vanilla_scheduler();
   MOCK(networkstatus_get_param, mock_vanilla_networkstatus_get_param);
   scheduler_notify_networkstatus_changed(NULL, NULL);
   UNMOCK(networkstatus_get_param);
-  tt_ptr_op(scheduler, ==, get_vanilla_scheduler());
+  tt_ptr_op(the_scheduler, ==, get_vanilla_scheduler());
 
  done:
   UNMOCK(get_options);



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits