mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-10 21:23:58 +01:00
Changes to 3199 branch based on feedback from special
This commit is contained in:
parent
eb721ed2d9
commit
661e5bdbfa
@ -1455,7 +1455,7 @@ run_scheduled_events(time_t now)
|
|||||||
dirvote_act(options, now);
|
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.
|
* ones which have been pending for more than a few seconds.
|
||||||
* We do this before step 4, so it can try building more if
|
* We do this before step 4, so it can try building more if
|
||||||
* it's not comfortable with the number of available circuits.
|
* it's not comfortable with the number of available circuits.
|
||||||
@ -1545,7 +1545,7 @@ rotate_onion_key_callback(time_t now, const or_options_t *options)
|
|||||||
router_upload_dir_desc_to_dirservers(0);
|
router_upload_dir_desc_to_dirservers(0);
|
||||||
return MIN_ONION_KEY_LIFETIME;
|
return MIN_ONION_KEY_LIFETIME;
|
||||||
}
|
}
|
||||||
return -1;
|
return PERIODIC_EVENT_NO_UPDATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -1562,21 +1562,21 @@ check_ed_keys_callback(time_t now, const or_options_t *options)
|
|||||||
}
|
}
|
||||||
return 30;
|
return 30;
|
||||||
}
|
}
|
||||||
return -1;
|
return PERIODIC_EVENT_NO_UPDATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
launch_descriptor_fetches_callback(time_t now, const or_options_t *options)
|
launch_descriptor_fetches_callback(time_t now, const or_options_t *options)
|
||||||
{
|
{
|
||||||
if (should_delay_dir_fetches(options, NULL))
|
if (should_delay_dir_fetches(options, NULL))
|
||||||
return -1;
|
return PERIODIC_EVENT_NO_UPDATE;
|
||||||
|
|
||||||
update_all_descriptor_downloads(now);
|
update_all_descriptor_downloads(now);
|
||||||
update_extrainfo_downloads(now);
|
update_extrainfo_downloads(now);
|
||||||
if (router_have_minimum_dir_info())
|
if (router_have_minimum_dir_info())
|
||||||
return LAZY_DESCRIPTOR_RETRY_INTERVAL;
|
return LAZY_DESCRIPTOR_RETRY_INTERVAL;
|
||||||
else
|
else
|
||||||
return GREEDY_DESCRIPTOR_RETRY_INTERVAL;
|
return GREEDY_DESCRIPTOR_RETRY_INTERVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -1609,7 +1609,7 @@ rotate_x509_certificate_callback(time_t now, const or_options_t *options)
|
|||||||
|
|
||||||
/* We also make sure to rotate the TLS connections themselves if they've
|
/* 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
|
* 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;
|
return MAX_SSL_KEY_LIFETIME_INTERNAL;
|
||||||
}
|
}
|
||||||
@ -1763,7 +1763,7 @@ record_bridge_stats_callback(time_t now, const or_options_t *options)
|
|||||||
* next time bridge mode is turned on. */
|
* next time bridge mode is turned on. */
|
||||||
should_init_bridge_stats = 1;
|
should_init_bridge_stats = 1;
|
||||||
}
|
}
|
||||||
return -1;
|
return PERIODIC_EVENT_NO_UPDATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -1877,7 +1877,7 @@ fetch_networkstatus_callback(time_t now, const or_options_t *options)
|
|||||||
#define networkstatus_dl_check_interval(o) ((o)->TestingTorNetwork ? 1 : 60)
|
#define networkstatus_dl_check_interval(o) ((o)->TestingTorNetwork ? 1 : 60)
|
||||||
|
|
||||||
if (should_delay_dir_fetches(options, NULL))
|
if (should_delay_dir_fetches(options, NULL))
|
||||||
return -1;
|
return PERIODIC_EVENT_NO_UPDATE;
|
||||||
|
|
||||||
update_networkstatus_downloads(now);
|
update_networkstatus_downloads(now);
|
||||||
return networkstatus_dl_check_interval(options);
|
return networkstatus_dl_check_interval(options);
|
||||||
@ -1893,7 +1893,7 @@ retry_listeners_callback(time_t now, const or_options_t *options)
|
|||||||
retry_all_listeners(NULL, NULL, 0);
|
retry_all_listeners(NULL, NULL, 0);
|
||||||
return 60;
|
return 60;
|
||||||
}
|
}
|
||||||
return -1;
|
return PERIODIC_EVENT_NO_UPDATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -1914,7 +1914,7 @@ check_dns_honesty_callback(time_t now, const or_options_t *options)
|
|||||||
if (net_is_disabled() ||
|
if (net_is_disabled() ||
|
||||||
! public_server_mode(options) ||
|
! public_server_mode(options) ||
|
||||||
router_my_exit_policy_is_reject_star())
|
router_my_exit_policy_is_reject_star())
|
||||||
return -1;
|
return PERIODIC_EVENT_NO_UPDATE;
|
||||||
|
|
||||||
static int first_time = 1;
|
static int first_time = 1;
|
||||||
if (first_time) {
|
if (first_time) {
|
||||||
@ -1936,7 +1936,7 @@ write_bridge_ns_callback(time_t now, const or_options_t *options)
|
|||||||
#define BRIDGE_STATUSFILE_INTERVAL (30*60)
|
#define BRIDGE_STATUSFILE_INTERVAL (30*60)
|
||||||
return BRIDGE_STATUSFILE_INTERVAL;
|
return BRIDGE_STATUSFILE_INTERVAL;
|
||||||
}
|
}
|
||||||
return -1;
|
return PERIODIC_EVENT_NO_UPDATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -1945,7 +1945,7 @@ check_fw_helper_app_callback(time_t now, const or_options_t *options)
|
|||||||
if (net_is_disabled() ||
|
if (net_is_disabled() ||
|
||||||
! server_mode(options) ||
|
! server_mode(options) ||
|
||||||
! options->PortForwarding) {
|
! options->PortForwarding) {
|
||||||
return -1;
|
return PERIODIC_EVENT_NO_UPDATE;
|
||||||
}
|
}
|
||||||
/* 11. check the port forwarding app */
|
/* 11. check the port forwarding app */
|
||||||
|
|
||||||
|
@ -12,8 +12,9 @@
|
|||||||
#include <event.h>
|
#include <event.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** We disable any interval greate than this number of seconds, on the ground
|
/** We disable any interval greater than this number of seconds, on the
|
||||||
* that it is probably an absolute time mistakenly passed in as a relative time.
|
* grounds that it is probably an absolute time mistakenly passed in as a
|
||||||
|
* relative time.
|
||||||
*/
|
*/
|
||||||
static const int MAX_INTERVAL = 10 * 365 * 86400;
|
static const int MAX_INTERVAL = 10 * 365 * 86400;
|
||||||
|
|
||||||
@ -41,6 +42,7 @@ periodic_event_dispatch(evutil_socket_t fd, short what, void *data)
|
|||||||
|
|
||||||
time_t now = time(NULL);
|
time_t now = time(NULL);
|
||||||
const or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
|
log_debug(LD_GENERAL, "Dispatching %s", event->name);
|
||||||
int r = event->fn(now, options);
|
int r = event->fn(now, options);
|
||||||
int next_interval = 0;
|
int next_interval = 0;
|
||||||
|
|
||||||
@ -63,10 +65,10 @@ periodic_event_dispatch(evutil_socket_t fd, short what, void *data)
|
|||||||
next_interval = 1;
|
next_interval = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log_debug(LD_GENERAL, "Scheduling %s for %d seconds", event->name,
|
||||||
|
next_interval);
|
||||||
struct timeval tv = { next_interval , 0 };
|
struct timeval tv = { next_interval , 0 };
|
||||||
event_add(event->ev, &tv);
|
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. */
|
/** Schedules <b>event</b> to run as soon as possible from now. */
|
||||||
|
@ -4,12 +4,13 @@
|
|||||||
#ifndef TOR_PERIODIC_H
|
#ifndef TOR_PERIODIC_H
|
||||||
#define TOR_PERIODIC_H
|
#define TOR_PERIODIC_H
|
||||||
|
|
||||||
/** Callback function for a periodic event to take action.
|
#define PERIODIC_EVENT_NO_UPDATE (-1)
|
||||||
* 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
|
/** Callback function for a periodic event to take action. The return value
|
||||||
* the next second. If a positive value is returned it will update the
|
* influences the next time the function will get called. Return
|
||||||
* interval time. If the returned value is larger than <b>now</b> then it
|
* PERIODIC_EVENT_NO_UPDATE to not update <b>last_action_time</b> and be polled
|
||||||
* is assumed to be a future time to poll again. */
|
* 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,
|
typedef int (*periodic_event_helper_t)(time_t now,
|
||||||
const or_options_t *options);
|
const or_options_t *options);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user