8 #define SCHEDULER_PRIVATE
9 #define SCHEDULER_KIST_PRIVATE
13 #define CHANNEL_OBJECT_PRIVATE
174 static int have_logged_kist_suddenly_disabled = 0;
187 case SCHEDULER_VANILLA:
191 case SCHEDULER_KIST_LITE:
196 tor_assert_unreached();
211 log_debug(
LD_SCHED,
"Scheduler event callback called");
236 #ifdef TOR_UNIT_TESTS
250 case SCHEDULER_VANILLA:
251 new_scheduler = get_vanilla_scheduler();
254 if (!scheduler_can_use_kist()) {
255 #ifdef HAVE_KIST_SUPPORT
256 if (!have_logged_kist_suddenly_disabled) {
265 have_logged_kist_suddenly_disabled = 1;
266 log_notice(
LD_SCHED,
"Scheduler type KIST has been disabled by "
267 "the consensus or no kernel support.");
270 log_info(
LD_SCHED,
"Scheduler type KIST not built in");
281 have_logged_kist_suddenly_disabled = 0;
282 new_scheduler = get_kist_scheduler();
283 scheduler_kist_set_full_mode();
285 case SCHEDULER_KIST_LITE:
286 new_scheduler = get_kist_scheduler();
287 scheduler_kist_set_lite_mode();
293 tor_assert_unreached();
295 } SMARTLIST_FOREACH_END(type);
298 if (new_scheduler == NULL) {
299 log_err(
LD_SCHED,
"Tor was unable to select a scheduler type. Please "
300 "make sure Schedulers is correctly configured with "
301 "what Tor does support.");
340 if (old_scheduler && old_scheduler->free_all) {
341 old_scheduler->free_all();
353 log_info(
LD_CONFIG,
"Scheduler type %s has been enabled.",
368 switch (scheduler_state) {
369 case SCHED_CHAN_IDLE:
371 case SCHED_CHAN_WAITING_FOR_CELLS:
372 return "WAITING_FOR_CELLS";
373 case SCHED_CHAN_WAITING_TO_WRITE:
374 return "WAITING_TO_WRITE";
375 case SCHED_CHAN_PENDING:
387 log_debug(
LD_SCHED,
"chan %" PRIu64
" changed from scheduler state %s to %s",
408 uintptr_t p1_i, p2_i;
430 p1_i = (uintptr_t)p1;
431 p2_i = (uintptr_t)p2;
433 return (p1_i < p2_i) ? -1 : 1;
486 log_debug(
LD_SCHED,
"Shutting down scheduler");
590 log_warn(
LD_SCHED,
"Adding to libevent failed. Next run time was set to: "
591 "%ld.%06ld", next_run->tv_sec, (
long)next_run->tv_usec);
612 log_debug(
LD_SCHED,
"Initting scheduler");
616 log_warn(
LD_SCHED,
"We should not already have a libevent scheduler event."
617 "I'll clean the old one up, but this is odd.");
634 scheduler_release_channel,(
channel_t *chan))
710 scheduler_bug_occurred(
const channel_t *chan)
715 const size_t outbuf_len =
718 "Channel %" PRIu64
" in state %s and scheduler state %s."
719 " Num cells on cmux: %d. Connection outbuf len: %lu.",
724 (
unsigned long)outbuf_len);
731 static ratelim_t rlimit = RATELIM_INIT(60);
733 log_warn(
LD_BUG,
"%s Num pending channels: %d. "
734 "Channel in pending list: %s.%s",
735 (chan != NULL) ? buf :
"No channel in bug context.",
744 #ifdef TOR_UNIT_TESTS
size_t buf_datalen(const buf_t *buf)
Header file for buffers.c.
const char * channel_state_to_string(channel_state_t state)
Header file for channeltls.c.
int circuitmux_compare_muxes(circuitmux_t *cmux_1, circuitmux_t *cmux_2)
unsigned int circuitmux_num_cells(circuitmux_t *cmux)
const circuitmux_policy_t * circuitmux_get_policy(circuitmux_t *cmux)
mainloop_event_t * mainloop_event_new(void(*cb)(mainloop_event_t *, void *), void *userdata)
int mainloop_event_schedule(mainloop_event_t *event, const struct timeval *tv)
void mainloop_event_activate(mainloop_event_t *event)
Header for compat_libevent.c.
const or_options_t * get_options(void)
Header file for config.c.
Header file for mainloop.c.
Master header file for Tor-specific functionality.
int tor_snprintf(char *str, size_t size, const char *format,...)
char * rate_limit_log(ratelim_t *lim, time_t now)
void scheduler_notify_networkstatus_changed(void)
void scheduler_conf_changed(void)
void scheduler_ev_active(void)
void scheduler_free_all(void)
static void set_scheduler(void)
static const char * get_scheduler_type_string(scheduler_types_t type)
static void select_scheduler(void)
int scheduler_compare_channels(const void *c1_v, const void *c2_v)
void scheduler_set_channel_state(channel_t *chan, int new_state)
smartlist_t * get_channels_pending(void)
void scheduler_ev_add(const struct timeval *next_run)
void scheduler_channel_doesnt_want_writes(channel_t *chan)
const char * get_scheduler_state_string(int scheduler_state)
STATIC struct mainloop_event_t * run_sched_ev
void scheduler_channel_wants_writes(channel_t *chan)
void scheduler_channel_has_waiting_cells(channel_t *chan)
STATIC const scheduler_t * the_scheduler
static void scheduler_evt_callback(mainloop_event_t *event, void *arg)
STATIC smartlist_t * channels_pending
Header file for scheduler*.c.
int smartlist_pos(const smartlist_t *sl, const void *element)
void smartlist_pqueue_add(smartlist_t *sl, int(*compare)(const void *a, const void *b), ptrdiff_t idx_field_offset, void *item)
void smartlist_pqueue_remove(smartlist_t *sl, int(*compare)(const void *a, const void *b), ptrdiff_t idx_field_offset, void *item)
smartlist_t * smartlist_new(void)
#define SMARTLIST_FOREACH_BEGIN(sl, type, var)
enum channel_t::@9 scheduler_state
uint64_t global_identifier
#define MOCK_IMPL(rv, funcname, arglist)
#define IF_BUG_ONCE(cond)