mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-09-21 05:26:20 +02:00
Changes to 3199 branch based on feedback from special
This commit is contained in:
parent
eb721ed2d9
commit
661e5bdbfa
@ -1545,7 +1545,7 @@ rotate_onion_key_callback(time_t now, const or_options_t *options)
|
||||
router_upload_dir_desc_to_dirservers(0);
|
||||
return MIN_ONION_KEY_LIFETIME;
|
||||
}
|
||||
return -1;
|
||||
return PERIODIC_EVENT_NO_UPDATE;
|
||||
}
|
||||
|
||||
static int
|
||||
@ -1562,14 +1562,14 @@ check_ed_keys_callback(time_t now, const or_options_t *options)
|
||||
}
|
||||
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);
|
||||
@ -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
|
||||
* 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;
|
||||
}
|
||||
@ -1763,7 +1763,7 @@ record_bridge_stats_callback(time_t now, const or_options_t *options)
|
||||
* next time bridge mode is turned on. */
|
||||
should_init_bridge_stats = 1;
|
||||
}
|
||||
return -1;
|
||||
return PERIODIC_EVENT_NO_UPDATE;
|
||||
}
|
||||
|
||||
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)
|
||||
|
||||
if (should_delay_dir_fetches(options, NULL))
|
||||
return -1;
|
||||
return PERIODIC_EVENT_NO_UPDATE;
|
||||
|
||||
update_networkstatus_downloads(now);
|
||||
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);
|
||||
return 60;
|
||||
}
|
||||
return -1;
|
||||
return PERIODIC_EVENT_NO_UPDATE;
|
||||
}
|
||||
|
||||
static int
|
||||
@ -1914,7 +1914,7 @@ check_dns_honesty_callback(time_t now, const or_options_t *options)
|
||||
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) {
|
||||
@ -1936,7 +1936,7 @@ write_bridge_ns_callback(time_t now, const or_options_t *options)
|
||||
#define BRIDGE_STATUSFILE_INTERVAL (30*60)
|
||||
return BRIDGE_STATUSFILE_INTERVAL;
|
||||
}
|
||||
return -1;
|
||||
return PERIODIC_EVENT_NO_UPDATE;
|
||||
}
|
||||
|
||||
static int
|
||||
@ -1945,7 +1945,7 @@ check_fw_helper_app_callback(time_t now, const or_options_t *options)
|
||||
if (net_is_disabled() ||
|
||||
! server_mode(options) ||
|
||||
! options->PortForwarding) {
|
||||
return -1;
|
||||
return PERIODIC_EVENT_NO_UPDATE;
|
||||
}
|
||||
/* 11. check the port forwarding app */
|
||||
|
||||
|
@ -12,8 +12,9 @@
|
||||
#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;
|
||||
|
||||
@ -41,6 +42,7 @@ periodic_event_dispatch(evutil_socket_t fd, short what, void *data)
|
||||
|
||||
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;
|
||||
|
||||
@ -63,10 +65,10 @@ periodic_event_dispatch(evutil_socket_t fd, short what, void *data)
|
||||
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. */
|
||||
|
@ -4,12 +4,13 @@
|
||||
#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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user