tor  0.4.2.0-alpha-dev
or_periodic.c
Go to the documentation of this file.
1 /* Copyright (c) 2001 Matej Pfajfar.
2  * Copyright (c) 2001-2004, Roger Dingledine.
3  * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
4  * Copyright (c) 2007-2019, The Tor Project, Inc. */
5 /* See LICENSE for licensing information */
6 
12 #include "orconfig.h"
13 #include "core/or/or.h"
14 
15 #include "core/mainloop/periodic.h"
16 
17 #include "core/or/channel.h"
18 #include "core/or/circuituse.h"
19 #include "core/or/or_periodic.h"
20 
22 
23 #define DECLARE_EVENT(name, roles, flags) \
24  static periodic_event_item_t name ## _event = \
25  PERIODIC_EVENT(name, \
26  PERIODIC_EVENT_ROLE_##roles, \
27  flags)
28 
29 #define FL(name) (PERIODIC_EVENT_FLAG_ ## name)
30 
31 #define CHANNEL_CHECK_INTERVAL (60*60)
32 static int
33 check_canonical_channels_callback(time_t now, const or_options_t *options)
34 {
35  (void)now;
36  if (public_server_mode(options))
38 
39  return CHANNEL_CHECK_INTERVAL;
40 }
41 
42 DECLARE_EVENT(check_canonical_channels, RELAY, FL(NEED_NET));
43 
47 static int
49  const or_options_t *options)
50 {
51  (void)options;
52  /* every 11 seconds, so not usually the same second as other such events */
54  return 11;
55 }
56 
57 DECLARE_EVENT(expire_old_circuits_serverside, ROUTER, FL(NEED_NET));
58 
59 void
60 or_register_periodic_events(void)
61 {
62  // These are router-only events, but they're owned by the OR subsystem. */
63  periodic_events_register(&check_canonical_channels_event);
64  periodic_events_register(&expire_old_circuits_serverside_event);
65 }
static int expire_old_circuits_serverside_callback(time_t now, const or_options_t *options)
Definition: or_periodic.c:48
Header for core/or/or_periodic.c.
void periodic_events_register(periodic_event_item_t *item)
Definition: periodic.c:215
Header file for channel.c.
void circuit_expire_old_circuits_serverside(time_t now)
Definition: circuituse.c:1572
Header file for routermode.c.
void channel_check_for_duplicates(void)
Definition: channel.c:748
Master header file for Tor-specific functionality.
Header file for circuituse.c.