summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Perry <mikeperry-git@torproject.org>2023-06-20 16:29:48 +0000
committerMike Perry <mikeperry-git@torproject.org>2023-06-20 16:29:48 +0000
commit27a0fee88230d027dddad1e5d6b2adc991aec6c1 (patch)
treeb9cf59cb1654d2af7673da02883fc46b5d0b348d /src
parent846bad3a96587dd23b7370735f53031662e33919 (diff)
downloadtor-27a0fee88230d027dddad1e5d6b2adc991aec6c1.tar.gz
tor-27a0fee88230d027dddad1e5d6b2adc991aec6c1.zip
Bug 40808: Change KISTSchedRunInterval range and default; add KISTSchedRunIntervalClient
Diffstat (limited to 'src')
-rw-r--r--src/core/or/scheduler.h6
-rw-r--r--src/core/or/scheduler_kist.c14
-rw-r--r--src/test/test_scheduler.c10
3 files changed, 18 insertions, 12 deletions
diff --git a/src/core/or/scheduler.h b/src/core/or/scheduler.h
index 7d3c6f7390..dab7f37f0e 100644
--- a/src/core/or/scheduler.h
+++ b/src/core/or/scheduler.h
@@ -102,9 +102,9 @@ typedef struct scheduler_t {
*****************************************************************************/
/* Default interval that KIST runs (in ms). */
-#define KIST_SCHED_RUN_INTERVAL_DEFAULT 10
-/* Minimum interval that KIST runs. This value disables KIST. */
-#define KIST_SCHED_RUN_INTERVAL_MIN 0
+#define KIST_SCHED_RUN_INTERVAL_DEFAULT 2
+/* Minimum interval that KIST runs. */
+#define KIST_SCHED_RUN_INTERVAL_MIN 2
/* Maximum interval that KIST runs (in ms). */
#define KIST_SCHED_RUN_INTERVAL_MAX 100
diff --git a/src/core/or/scheduler_kist.c b/src/core/or/scheduler_kist.c
index 52bc62f1b4..69804247c8 100644
--- a/src/core/or/scheduler_kist.c
+++ b/src/core/or/scheduler_kist.c
@@ -13,6 +13,7 @@
#include "app/config/config.h"
#include "core/mainloop/connection.h"
#include "feature/nodelist/networkstatus.h"
+#include "feature/relay/routermode.h"
#define CHANNEL_OBJECT_PRIVATE
#include "core/or/channel.h"
#include "core/or/channeltls.h"
@@ -810,12 +811,19 @@ kist_scheduler_run_interval(void)
log_debug(LD_SCHED, "KISTSchedRunInterval=0, turning to the consensus.");
- /* 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(NULL, "KISTSchedRunInterval",
+ /* Clients and relays have a separate consensus parameter. Clients
+ * need a lower KIST interval, since they have only a couple connections */
+ if (server_mode(get_options())) {
+ return networkstatus_get_param(NULL, "KISTSchedRunInterval",
KIST_SCHED_RUN_INTERVAL_DEFAULT,
KIST_SCHED_RUN_INTERVAL_MIN,
KIST_SCHED_RUN_INTERVAL_MAX);
+ } else {
+ return networkstatus_get_param(NULL, "KISTSchedRunIntervalClient",
+ KIST_SCHED_RUN_INTERVAL_DEFAULT,
+ KIST_SCHED_RUN_INTERVAL_MIN,
+ KIST_SCHED_RUN_INTERVAL_MAX);
+ }
}
/* Set KISTLite mode that is KIST without kernel support. */
diff --git a/src/test/test_scheduler.c b/src/test/test_scheduler.c
index 7e41a4be25..06b3dafce8 100644
--- a/src/test/test_scheduler.c
+++ b/src/test/test_scheduler.c
@@ -81,8 +81,7 @@ mock_vanilla_networkstatus_get_param(
(void)default_val;
(void)min_val;
(void)max_val;
- // only support KISTSchedRunInterval right now
- tor_assert(strcmp(param_name, "KISTSchedRunInterval")==0);
+ (void)param_name;
return 0;
}
@@ -95,8 +94,7 @@ mock_kist_networkstatus_get_param(
(void)default_val;
(void)min_val;
(void)max_val;
- // only support KISTSchedRunInterval right now
- tor_assert(strcmp(param_name, "KISTSchedRunInterval")==0);
+ (void)param_name;
return 12;
}
@@ -863,7 +861,7 @@ test_scheduler_initfree(void *arg)
/* 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(the_scheduler, OP_EQ, get_kist_scheduler());
- tt_int_op(sched_run_interval, OP_EQ, 10);
+ tt_int_op(sched_run_interval, OP_EQ, KIST_SCHED_RUN_INTERVAL_DEFAULT);
scheduler_free_all();
@@ -906,7 +904,7 @@ test_scheduler_can_use_kist(void *arg)
#else /* HAVE_KIST_SUPPORT */
tt_int_op(res_should, OP_EQ, 0);
#endif /* HAVE_KIST_SUPPORT */
- tt_int_op(res_freq, OP_EQ, 10);
+ tt_int_op(res_freq, OP_EQ, KIST_SCHED_RUN_INTERVAL_DEFAULT);
/* Test defer to consensus, and kist consensus available */
MOCK(networkstatus_get_param, mock_kist_networkstatus_get_param);