dirvote_act(options, now);
}
- /* 3a. Every second, we examine pending circuits and prune the
+ /* 3a. Every second, we examine pending circuits and prune the
* ones which have been pending for more than a few seconds.
* We do this before step 4, so it can try building more if
* it's not comfortable with the number of available circuits.
router_upload_dir_desc_to_dirservers(0);
return MIN_ONION_KEY_LIFETIME;
}
- return -1;
+ return PERIODIC_EVENT_NO_UPDATE;
}
static int
}
return 30;
}
- return -1;
+ return PERIODIC_EVENT_NO_UPDATE;
}
static int
launch_descriptor_fetches_callback(time_t now, const or_options_t *options)
{
if (should_delay_dir_fetches(options, NULL))
- return -1;
+ return PERIODIC_EVENT_NO_UPDATE;
update_all_descriptor_downloads(now);
update_extrainfo_downloads(now);
if (router_have_minimum_dir_info())
return LAZY_DESCRIPTOR_RETRY_INTERVAL;
else
- return GREEDY_DESCRIPTOR_RETRY_INTERVAL;
+ return GREEDY_DESCRIPTOR_RETRY_INTERVAL;
}
static int
/* We also make sure to rotate the TLS connections themselves if they've
* been up for too long -- but that's done via is_bad_for_new_circs in
- * connection_run_housekeeping() above. */
+ * run_connection_housekeeping() above. */
return MAX_SSL_KEY_LIFETIME_INTERNAL;
}
* next time bridge mode is turned on. */
should_init_bridge_stats = 1;
}
- return -1;
+ return PERIODIC_EVENT_NO_UPDATE;
}
static int
#define networkstatus_dl_check_interval(o) ((o)->TestingTorNetwork ? 1 : 60)
if (should_delay_dir_fetches(options, NULL))
- return -1;
+ return PERIODIC_EVENT_NO_UPDATE;
update_networkstatus_downloads(now);
return networkstatus_dl_check_interval(options);
retry_all_listeners(NULL, NULL, 0);
return 60;
}
- return -1;
+ return PERIODIC_EVENT_NO_UPDATE;
}
static int
if (net_is_disabled() ||
! public_server_mode(options) ||
router_my_exit_policy_is_reject_star())
- return -1;
+ return PERIODIC_EVENT_NO_UPDATE;
static int first_time = 1;
if (first_time) {
#define BRIDGE_STATUSFILE_INTERVAL (30*60)
return BRIDGE_STATUSFILE_INTERVAL;
}
- return -1;
+ return PERIODIC_EVENT_NO_UPDATE;
}
static int
if (net_is_disabled() ||
! server_mode(options) ||
! options->PortForwarding) {
- return -1;
+ return PERIODIC_EVENT_NO_UPDATE;
}
/* 11. check the port forwarding app */
#include <event.h>
#endif
-/** We disable any interval greate than this number of seconds, on the ground
- * that it is probably an absolute time mistakenly passed in as a relative time.
+/** We disable any interval greater than this number of seconds, on the
+ * grounds that it is probably an absolute time mistakenly passed in as a
+ * relative time.
*/
static const int MAX_INTERVAL = 10 * 365 * 86400;
time_t now = time(NULL);
const or_options_t *options = get_options();
+ log_debug(LD_GENERAL, "Dispatching %s", event->name);
int r = event->fn(now, options);
int next_interval = 0;
next_interval = 1;
}
+ log_debug(LD_GENERAL, "Scheduling %s for %d seconds", event->name,
+ next_interval);
struct timeval tv = { next_interval , 0 };
event_add(event->ev, &tv);
-
- log_info(LD_GENERAL, "Dispatching %s", event->name);
}
/** Schedules <b>event</b> to run as soon as possible from now. */
#ifndef TOR_PERIODIC_H
#define TOR_PERIODIC_H
-/** Callback function for a periodic event to take action.
-* The return value influences the next time the function will get called.
-* Return -1 to not update <b>last_action_time</b> and be polled again in
-* the next second. If a positive value is returned it will update the
-* interval time. If the returned value is larger than <b>now</b> then it
-* is assumed to be a future time to poll again. */
+#define PERIODIC_EVENT_NO_UPDATE (-1)
+
+/** Callback function for a periodic event to take action. The return value
+* influences the next time the function will get called. Return
+* PERIODIC_EVENT_NO_UPDATE to not update <b>last_action_time</b> and be polled
+* again in the next second. If a positive value is returned it will update the
+* interval time. */
typedef int (*periodic_event_helper_t)(time_t now,
const or_options_t *options);