mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-10 21:23:58 +01:00
sched: revisist compatibility on non-linux systems
Wrap things in HAVE_KIST_SUPPORT until Tor compiles and tests cleanly on my OS X machine.
This commit is contained in:
parent
8ccb2c106a
commit
4bc97c6431
@ -17,8 +17,10 @@
|
||||
|
||||
#define TLS_PER_CELL_OVERHEAD 29
|
||||
|
||||
#ifdef HAVE_KIST_SUPPORT
|
||||
/* Kernel interface needed for KIST. */
|
||||
#include <linux/sockios.h>
|
||||
#endif /* HAVE_KIST_SUPPORT */
|
||||
|
||||
/*****************************************************************************
|
||||
* Data structures and supporting functions
|
||||
@ -27,7 +29,9 @@
|
||||
/* Indicate if we don't have the kernel support. This can happen if the kernel
|
||||
* changed and it doesn't recognized the values passed to the syscalls needed
|
||||
* by KIST. In that case, fallback to the naive approach. */
|
||||
#ifdef HAVE_KIST_SUPPORT
|
||||
static unsigned int kist_no_kernel_support = 0;
|
||||
#endif /* HAVE_KIST_SUPPORT */
|
||||
|
||||
/* Socket_table hash table stuff. The socket_table keeps track of per-socket
|
||||
* limit information imposed by kist and used by kist. */
|
||||
@ -182,6 +186,7 @@ free_socket_info_by_chan(socket_table_t *table, const channel_t *chan)
|
||||
MOCK_IMPL(void,
|
||||
update_socket_info_impl, (socket_table_ent_t *ent))
|
||||
{
|
||||
#ifdef HAVE_KIST_SUPPORT
|
||||
int64_t tcp_space, extra_space;
|
||||
const tor_socket_t sock =
|
||||
TO_CONN(BASE_CHAN_TO_TLS((channel_t *) ent->chan)->conn)->s;
|
||||
@ -244,6 +249,10 @@ update_socket_info_impl, (socket_table_ent_t *ent))
|
||||
ent->limit = tcp_space + extra_space;
|
||||
return;
|
||||
|
||||
#else /* HAVE_KIST_SUPPORT */
|
||||
goto fallback;
|
||||
#endif /* HAVE_KIST_SUPPORT */
|
||||
|
||||
fallback:
|
||||
/* If all of a sudden we don't have kist support, we just zero out all the
|
||||
* variables for this socket since we don't know what they should be.
|
||||
|
@ -845,7 +845,9 @@ test_scheduler_channel_states(void *arg)
|
||||
{
|
||||
(void)arg;
|
||||
perform_channel_state_tests(-1); // vanilla
|
||||
#ifdef HAVE_KIST_SUPPORT
|
||||
perform_channel_state_tests(11); // kist
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
@ -865,7 +867,11 @@ 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 */
|
||||
#ifdef HAVE_KIST_SUPPORT
|
||||
tt_ptr_op(the_scheduler, ==, get_kist_scheduler());
|
||||
#else
|
||||
tt_ptr_op(the_scheduler, ==, get_vanilla_scheduler());
|
||||
#endif
|
||||
tt_int_op(sched_run_interval, ==, 10);
|
||||
|
||||
scheduler_free_all();
|
||||
@ -901,7 +907,11 @@ test_scheduler_should_use_kist(void *arg)
|
||||
mocked_options.KISTSchedRunInterval = 1234;
|
||||
res_should = scheduler_should_use_kist();
|
||||
res_freq = kist_scheduler_run_interval(NULL);
|
||||
#ifdef HAVE_KIST_SUPPORT
|
||||
tt_int_op(res_should, ==, 1);
|
||||
#else /* HAVE_KIST_SUPPORT */
|
||||
tt_int_op(res_should, ==, 0);
|
||||
#endif /* HAVE_KIST_SUPPORT */
|
||||
tt_int_op(res_freq, ==, 1234);
|
||||
|
||||
/* Test defer to consensus, but no consensus available */
|
||||
@ -909,7 +919,11 @@ test_scheduler_should_use_kist(void *arg)
|
||||
mocked_options.KISTSchedRunInterval = 0;
|
||||
res_should = scheduler_should_use_kist();
|
||||
res_freq = kist_scheduler_run_interval(NULL);
|
||||
#ifdef HAVE_KIST_SUPPORT
|
||||
tt_int_op(res_should, ==, 1);
|
||||
#else /* HAVE_KIST_SUPPORT */
|
||||
tt_int_op(res_should, ==, 0);
|
||||
#endif /* HAVE_KIST_SUPPORT */
|
||||
tt_int_op(res_freq, ==, 10);
|
||||
|
||||
/* Test defer to consensus, and kist consensus available */
|
||||
@ -918,7 +932,11 @@ test_scheduler_should_use_kist(void *arg)
|
||||
mocked_options.KISTSchedRunInterval = 0;
|
||||
res_should = scheduler_should_use_kist();
|
||||
res_freq = kist_scheduler_run_interval(NULL);
|
||||
#ifdef HAVE_KIST_SUPPORT
|
||||
tt_int_op(res_should, ==, 1);
|
||||
#else /* HAVE_KIST_SUPPORT */
|
||||
tt_int_op(res_should, ==, 0);
|
||||
#endif /* HAVE_KIST_SUPPORT */
|
||||
tt_int_op(res_freq, ==, 12);
|
||||
UNMOCK(networkstatus_get_param);
|
||||
|
||||
@ -961,7 +979,11 @@ test_scheduler_ns_changed(void *arg)
|
||||
MOCK(networkstatus_get_param, mock_kist_networkstatus_get_param);
|
||||
scheduler_notify_networkstatus_changed(NULL, NULL);
|
||||
UNMOCK(networkstatus_get_param);
|
||||
#ifdef HAVE_KIST_SUPPORT
|
||||
tt_ptr_op(the_scheduler, ==, get_kist_scheduler());
|
||||
#else
|
||||
tt_ptr_op(the_scheduler, ==, get_vanilla_scheduler());
|
||||
#endif
|
||||
|
||||
/* Change from kist to vanilla via consensus */
|
||||
the_scheduler = get_kist_scheduler();
|
||||
@ -975,7 +997,11 @@ test_scheduler_ns_changed(void *arg)
|
||||
MOCK(networkstatus_get_param, mock_kist_networkstatus_get_param);
|
||||
scheduler_notify_networkstatus_changed(NULL, NULL);
|
||||
UNMOCK(networkstatus_get_param);
|
||||
#ifdef HAVE_KIST_SUPPORT
|
||||
tt_ptr_op(the_scheduler, ==, get_kist_scheduler());
|
||||
#else
|
||||
tt_ptr_op(the_scheduler, ==, get_vanilla_scheduler());
|
||||
#endif
|
||||
|
||||
/* Doesn't change when using vanilla */
|
||||
the_scheduler = get_vanilla_scheduler();
|
||||
|
Loading…
Reference in New Issue
Block a user