mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-06 19:41:15 +01:00
ns: Add a before and after consensus has changed notification
In 0.3.2.1-alpha, we've added notify_networkstatus_changed() in order to have a way to notify other subsystems that the consensus just changed. The old and new consensus are passed to it. Before this patch, this was done _before_ the new consensus was set globally (thus NOT accessible by getting the latest consensus). The scheduler notification was assuming that it was set and select_scheduler() is looking at the latest consensus to get the parameters it might needs. This was very wrong because at that point it is still the old consensus set globally. This commit changes the notify_networkstatus_changed() to be the "before" function and adds an "after" notification from which the scheduler subsystem is notified. Fixes #24975
This commit is contained in:
@@ -959,7 +959,7 @@ test_scheduler_can_use_kist(void *arg)
|
||||
clear_options();
|
||||
mocked_options.KISTSchedRunInterval = 1234;
|
||||
res_should = scheduler_can_use_kist();
|
||||
res_freq = kist_scheduler_run_interval(NULL);
|
||||
res_freq = kist_scheduler_run_interval();
|
||||
#ifdef HAVE_KIST_SUPPORT
|
||||
tt_int_op(res_should, ==, 1);
|
||||
#else /* HAVE_KIST_SUPPORT */
|
||||
@@ -971,7 +971,7 @@ test_scheduler_can_use_kist(void *arg)
|
||||
clear_options();
|
||||
mocked_options.KISTSchedRunInterval = 0;
|
||||
res_should = scheduler_can_use_kist();
|
||||
res_freq = kist_scheduler_run_interval(NULL);
|
||||
res_freq = kist_scheduler_run_interval();
|
||||
#ifdef HAVE_KIST_SUPPORT
|
||||
tt_int_op(res_should, ==, 1);
|
||||
#else /* HAVE_KIST_SUPPORT */
|
||||
@@ -984,7 +984,7 @@ test_scheduler_can_use_kist(void *arg)
|
||||
clear_options();
|
||||
mocked_options.KISTSchedRunInterval = 0;
|
||||
res_should = scheduler_can_use_kist();
|
||||
res_freq = kist_scheduler_run_interval(NULL);
|
||||
res_freq = kist_scheduler_run_interval();
|
||||
#ifdef HAVE_KIST_SUPPORT
|
||||
tt_int_op(res_should, ==, 1);
|
||||
#else /* HAVE_KIST_SUPPORT */
|
||||
@@ -998,7 +998,7 @@ test_scheduler_can_use_kist(void *arg)
|
||||
clear_options();
|
||||
mocked_options.KISTSchedRunInterval = 0;
|
||||
res_should = scheduler_can_use_kist();
|
||||
res_freq = kist_scheduler_run_interval(NULL);
|
||||
res_freq = kist_scheduler_run_interval();
|
||||
tt_int_op(res_should, ==, 0);
|
||||
tt_int_op(res_freq, ==, 0);
|
||||
UNMOCK(networkstatus_get_param);
|
||||
@@ -1032,7 +1032,7 @@ test_scheduler_ns_changed(void *arg)
|
||||
/* Change from vanilla to kist via consensus */
|
||||
the_scheduler = get_vanilla_scheduler();
|
||||
MOCK(networkstatus_get_param, mock_kist_networkstatus_get_param);
|
||||
scheduler_notify_networkstatus_changed(NULL, NULL);
|
||||
scheduler_notify_networkstatus_changed();
|
||||
UNMOCK(networkstatus_get_param);
|
||||
#ifdef HAVE_KIST_SUPPORT
|
||||
tt_ptr_op(the_scheduler, ==, get_kist_scheduler());
|
||||
@@ -1043,14 +1043,14 @@ test_scheduler_ns_changed(void *arg)
|
||||
/* Change from kist to vanilla via consensus */
|
||||
the_scheduler = get_kist_scheduler();
|
||||
MOCK(networkstatus_get_param, mock_vanilla_networkstatus_get_param);
|
||||
scheduler_notify_networkstatus_changed(NULL, NULL);
|
||||
scheduler_notify_networkstatus_changed();
|
||||
UNMOCK(networkstatus_get_param);
|
||||
tt_ptr_op(the_scheduler, ==, get_vanilla_scheduler());
|
||||
|
||||
/* Doesn't change when using KIST */
|
||||
the_scheduler = get_kist_scheduler();
|
||||
MOCK(networkstatus_get_param, mock_kist_networkstatus_get_param);
|
||||
scheduler_notify_networkstatus_changed(NULL, NULL);
|
||||
scheduler_notify_networkstatus_changed();
|
||||
UNMOCK(networkstatus_get_param);
|
||||
#ifdef HAVE_KIST_SUPPORT
|
||||
tt_ptr_op(the_scheduler, ==, get_kist_scheduler());
|
||||
@@ -1061,7 +1061,7 @@ test_scheduler_ns_changed(void *arg)
|
||||
/* Doesn't change when using vanilla */
|
||||
the_scheduler = get_vanilla_scheduler();
|
||||
MOCK(networkstatus_get_param, mock_vanilla_networkstatus_get_param);
|
||||
scheduler_notify_networkstatus_changed(NULL, NULL);
|
||||
scheduler_notify_networkstatus_changed();
|
||||
UNMOCK(networkstatus_get_param);
|
||||
tt_ptr_op(the_scheduler, ==, get_vanilla_scheduler());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user