aboutsummaryrefslogtreecommitdiff
path: root/src/or/scheduler_kist.c
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@torproject.org>2018-01-31 14:15:02 -0500
committerDavid Goulet <dgoulet@torproject.org>2018-01-31 14:15:02 -0500
commitfbc455cbd224aaf28c613ed92bbaee656291efec (patch)
tree40486321ab7fda0b61fd3da012e42fec3853fa67 /src/or/scheduler_kist.c
parentc85f78e74c52d19b575618d031e67b64210c14fc (diff)
downloadtor-fbc455cbd224aaf28c613ed92bbaee656291efec.tar.gz
tor-fbc455cbd224aaf28c613ed92bbaee656291efec.zip
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
Diffstat (limited to 'src/or/scheduler_kist.c')
-rw-r--r--src/or/scheduler_kist.c20
1 files changed, 8 insertions, 12 deletions
diff --git a/src/or/scheduler_kist.c b/src/or/scheduler_kist.c
index f50f3aa9e9..877e561e01 100644
--- a/src/or/scheduler_kist.c
+++ b/src/or/scheduler_kist.c
@@ -362,10 +362,10 @@ outbuf_table_remove(outbuf_table_t *table, channel_t *chan)
/* Set the scheduler running interval. */
static void
-set_scheduler_run_interval(const networkstatus_t *ns)
+set_scheduler_run_interval(void)
{
int old_sched_run_interval = sched_run_interval;
- sched_run_interval = kist_scheduler_run_interval(ns);
+ sched_run_interval = kist_scheduler_run_interval();
if (old_sched_run_interval != sched_run_interval) {
log_info(LD_SCHED, "Scheduler KIST changing its running interval "
"from %" PRId32 " to %" PRId32,
@@ -481,13 +481,9 @@ kist_on_channel_free(const channel_t *chan)
/* Function of the scheduler interface: on_new_consensus() */
static void
-kist_scheduler_on_new_consensus(const networkstatus_t *old_c,
- const networkstatus_t *new_c)
+kist_scheduler_on_new_consensus(void)
{
- (void) old_c;
- (void) new_c;
-
- set_scheduler_run_interval(new_c);
+ set_scheduler_run_interval();
}
/* Function of the scheduler interface: on_new_options() */
@@ -497,7 +493,7 @@ kist_scheduler_on_new_options(void)
sock_buf_size_factor = get_options()->KISTSockBufSizeFactor;
/* Calls kist_scheduler_run_interval which calls get_options(). */
- set_scheduler_run_interval(NULL);
+ set_scheduler_run_interval();
}
/* Function of the scheduler interface: init() */
@@ -770,7 +766,7 @@ get_kist_scheduler(void)
* - If consensus doesn't say anything, return 10 milliseconds, default.
*/
int
-kist_scheduler_run_interval(const networkstatus_t *ns)
+kist_scheduler_run_interval(void)
{
int run_interval = get_options()->KISTSchedRunInterval;
@@ -784,7 +780,7 @@ kist_scheduler_run_interval(const networkstatus_t *ns)
/* Will either be the consensus value or the default. Note that 0 can be
* returned which means the consensus wants us to NOT use KIST. */
- return networkstatus_get_param(ns, "KISTSchedRunInterval",
+ return networkstatus_get_param(NULL, "KISTSchedRunInterval",
KIST_SCHED_RUN_INTERVAL_DEFAULT,
KIST_SCHED_RUN_INTERVAL_MIN,
KIST_SCHED_RUN_INTERVAL_MAX);
@@ -823,7 +819,7 @@ scheduler_can_use_kist(void)
/* We do have the support, time to check if we can get the interval that the
* consensus can be disabling. */
- int run_interval = kist_scheduler_run_interval(NULL);
+ int run_interval = kist_scheduler_run_interval();
log_debug(LD_SCHED, "Determined KIST sched_run_interval should be "
"%" PRId32 ". Can%s use KIST.",
run_interval, (run_interval > 0 ? "" : " not"));