mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-28 06:13:31 +01:00
sched: rename scheduler to the_scheduler
This commit is contained in:
parent
7f1d643083
commit
8ccb2c106a
@ -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;
|
||||
|
@ -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 */
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user