mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-28 14:23:30 +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
|
#define TLS_PER_CELL_OVERHEAD 29
|
||||||
|
|
||||||
|
#ifdef HAVE_KIST_SUPPORT
|
||||||
/* Kernel interface needed for KIST. */
|
/* Kernel interface needed for KIST. */
|
||||||
#include <linux/sockios.h>
|
#include <linux/sockios.h>
|
||||||
|
#endif /* HAVE_KIST_SUPPORT */
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* Data structures and supporting functions
|
* Data structures and supporting functions
|
||||||
@ -27,7 +29,9 @@
|
|||||||
/* Indicate if we don't have the kernel support. This can happen if the kernel
|
/* 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
|
* changed and it doesn't recognized the values passed to the syscalls needed
|
||||||
* by KIST. In that case, fallback to the naive approach. */
|
* by KIST. In that case, fallback to the naive approach. */
|
||||||
|
#ifdef HAVE_KIST_SUPPORT
|
||||||
static unsigned int kist_no_kernel_support = 0;
|
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
|
/* Socket_table hash table stuff. The socket_table keeps track of per-socket
|
||||||
* limit information imposed by kist and used by kist. */
|
* 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,
|
MOCK_IMPL(void,
|
||||||
update_socket_info_impl, (socket_table_ent_t *ent))
|
update_socket_info_impl, (socket_table_ent_t *ent))
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_KIST_SUPPORT
|
||||||
int64_t tcp_space, extra_space;
|
int64_t tcp_space, extra_space;
|
||||||
const tor_socket_t sock =
|
const tor_socket_t sock =
|
||||||
TO_CONN(BASE_CHAN_TO_TLS((channel_t *) ent->chan)->conn)->s;
|
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;
|
ent->limit = tcp_space + extra_space;
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
#else /* HAVE_KIST_SUPPORT */
|
||||||
|
goto fallback;
|
||||||
|
#endif /* HAVE_KIST_SUPPORT */
|
||||||
|
|
||||||
fallback:
|
fallback:
|
||||||
/* If all of a sudden we don't have kist support, we just zero out all the
|
/* 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.
|
* 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;
|
(void)arg;
|
||||||
perform_channel_state_tests(-1); // vanilla
|
perform_channel_state_tests(-1); // vanilla
|
||||||
|
#ifdef HAVE_KIST_SUPPORT
|
||||||
perform_channel_state_tests(11); // kist
|
perform_channel_state_tests(11); // kist
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -865,7 +867,11 @@ test_scheduler_initfree(void *arg)
|
|||||||
tt_ptr_op(run_sched_ev, !=, NULL);
|
tt_ptr_op(run_sched_ev, !=, NULL);
|
||||||
/* We have specified nothing in the torrc and there's no consensus so the
|
/* We have specified nothing in the torrc and there's no consensus so the
|
||||||
* KIST scheduler is what should be in use */
|
* KIST scheduler is what should be in use */
|
||||||
|
#ifdef HAVE_KIST_SUPPORT
|
||||||
tt_ptr_op(the_scheduler, ==, get_kist_scheduler());
|
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);
|
tt_int_op(sched_run_interval, ==, 10);
|
||||||
|
|
||||||
scheduler_free_all();
|
scheduler_free_all();
|
||||||
@ -901,7 +907,11 @@ test_scheduler_should_use_kist(void *arg)
|
|||||||
mocked_options.KISTSchedRunInterval = 1234;
|
mocked_options.KISTSchedRunInterval = 1234;
|
||||||
res_should = scheduler_should_use_kist();
|
res_should = scheduler_should_use_kist();
|
||||||
res_freq = kist_scheduler_run_interval(NULL);
|
res_freq = kist_scheduler_run_interval(NULL);
|
||||||
|
#ifdef HAVE_KIST_SUPPORT
|
||||||
tt_int_op(res_should, ==, 1);
|
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);
|
tt_int_op(res_freq, ==, 1234);
|
||||||
|
|
||||||
/* Test defer to consensus, but no consensus available */
|
/* Test defer to consensus, but no consensus available */
|
||||||
@ -909,7 +919,11 @@ test_scheduler_should_use_kist(void *arg)
|
|||||||
mocked_options.KISTSchedRunInterval = 0;
|
mocked_options.KISTSchedRunInterval = 0;
|
||||||
res_should = scheduler_should_use_kist();
|
res_should = scheduler_should_use_kist();
|
||||||
res_freq = kist_scheduler_run_interval(NULL);
|
res_freq = kist_scheduler_run_interval(NULL);
|
||||||
|
#ifdef HAVE_KIST_SUPPORT
|
||||||
tt_int_op(res_should, ==, 1);
|
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);
|
tt_int_op(res_freq, ==, 10);
|
||||||
|
|
||||||
/* Test defer to consensus, and kist consensus available */
|
/* Test defer to consensus, and kist consensus available */
|
||||||
@ -918,7 +932,11 @@ test_scheduler_should_use_kist(void *arg)
|
|||||||
mocked_options.KISTSchedRunInterval = 0;
|
mocked_options.KISTSchedRunInterval = 0;
|
||||||
res_should = scheduler_should_use_kist();
|
res_should = scheduler_should_use_kist();
|
||||||
res_freq = kist_scheduler_run_interval(NULL);
|
res_freq = kist_scheduler_run_interval(NULL);
|
||||||
|
#ifdef HAVE_KIST_SUPPORT
|
||||||
tt_int_op(res_should, ==, 1);
|
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);
|
tt_int_op(res_freq, ==, 12);
|
||||||
UNMOCK(networkstatus_get_param);
|
UNMOCK(networkstatus_get_param);
|
||||||
|
|
||||||
@ -961,7 +979,11 @@ test_scheduler_ns_changed(void *arg)
|
|||||||
MOCK(networkstatus_get_param, mock_kist_networkstatus_get_param);
|
MOCK(networkstatus_get_param, mock_kist_networkstatus_get_param);
|
||||||
scheduler_notify_networkstatus_changed(NULL, NULL);
|
scheduler_notify_networkstatus_changed(NULL, NULL);
|
||||||
UNMOCK(networkstatus_get_param);
|
UNMOCK(networkstatus_get_param);
|
||||||
|
#ifdef HAVE_KIST_SUPPORT
|
||||||
tt_ptr_op(the_scheduler, ==, get_kist_scheduler());
|
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 */
|
/* Change from kist to vanilla via consensus */
|
||||||
the_scheduler = get_kist_scheduler();
|
the_scheduler = get_kist_scheduler();
|
||||||
@ -975,7 +997,11 @@ test_scheduler_ns_changed(void *arg)
|
|||||||
MOCK(networkstatus_get_param, mock_kist_networkstatus_get_param);
|
MOCK(networkstatus_get_param, mock_kist_networkstatus_get_param);
|
||||||
scheduler_notify_networkstatus_changed(NULL, NULL);
|
scheduler_notify_networkstatus_changed(NULL, NULL);
|
||||||
UNMOCK(networkstatus_get_param);
|
UNMOCK(networkstatus_get_param);
|
||||||
|
#ifdef HAVE_KIST_SUPPORT
|
||||||
tt_ptr_op(the_scheduler, ==, get_kist_scheduler());
|
tt_ptr_op(the_scheduler, ==, get_kist_scheduler());
|
||||||
|
#else
|
||||||
|
tt_ptr_op(the_scheduler, ==, get_vanilla_scheduler());
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Doesn't change when using vanilla */
|
/* Doesn't change when using vanilla */
|
||||||
the_scheduler = get_vanilla_scheduler();
|
the_scheduler = get_vanilla_scheduler();
|
||||||
|
Loading…
Reference in New Issue
Block a user