aboutsummaryrefslogtreecommitdiff
path: root/src/or/main.c
AgeCommit message (Collapse)Author
2018-05-10Merge branch 'ticket26063_squashed'Nick Mathewson
2018-05-10Merge branch 'ticket26064'Nick Mathewson
2018-05-10Add a new function to enable/disable the per-second timer as neededNick Mathewson
We're about to use this to turn off the per-second timer when the network is disabled and there aren't any per-second controller events enabled.
2018-05-10Merge remote-tracking branch 'dgoulet/ticket26062_034_01'Nick Mathewson
2018-05-09Merge branch 'ticket26016'Nick Mathewson
2018-05-09Merge branch 'ticket26009'Nick Mathewson
2018-05-09spelling fixNick Mathewson
2018-05-09Fix some clang warningsNick Mathewson
2018-05-09Mark the 1-per-sec update_current_time() call as redundant.Nick Mathewson
We still do this time update here, since we do it from all callbacks, but it is no longer a reason to keep the once-per-second callback enabled. Closes ticket 26009.
2018-05-09Distinguish true clock jumps from idlenessNick Mathewson
Since we're going to be disabling the second-elapsed callback, we're going to sometimes have long periods when no events file, and so the current second is not updated. Handle that by having a better means to detect "clock jumps" as opposed to "being idle for a while". Tolerate far more of the latter. Part of #26009.
2018-05-09Give responsibility for waking up from DORMANT to a mainloop eventNick Mathewson
Closes ticket 26064.
2018-05-09config: Move any_client_port_set() to config.cDavid Goulet
This functions is now used outside of networkstatus.c and makes more sense to be in config.c. It is also renamed to options_any_client_port_set() for the config.c namespace. No code behavior change. Signed-off-by: David Goulet <dgoulet@torproject.org>
2018-05-09Comment-only fix: annotate we_are_hibernating() usageNick Mathewson
Everywhere we use we_are_hibernating(), remind the reader what it means. (Also, add an XXXX to note a DisableNetwork usage to change later.)
2018-05-09Give control.c responsibility for its own once-a-second eventsNick Mathewson
Now it has a function that can tell the rest of Tor whether any once-a-second controller item should fire, and a function to fire all the once-a-second events.
2018-05-03Merge remote-tracking branch 'isis/bug24660_r1'Nick Mathewson
2018-05-03Merge remote-tracking branch 'dgoulet/ticket25990_034_01'Nick Mathewson
2018-05-03Refactor to remove n_libevent_errorsNick Mathewson
We cleared this value in second_elapsed_callback. But what were we using it for? For detecting if Libevent returned EINVAL too often! We already have a way to detect too-frequent events, and that's with a ratelim_t. Refactor the code to use that instead. Closes ticket 26016.
2018-05-03Add update_current_time() calls to periodic and event-driven callbacksNick Mathewson
This is part of 26009, where we're going to keep track of the current time and its jumps without having to do so in second_elapsed_callback.
2018-05-03Move the "update the current second" code from second_elapsed_callbackNick Mathewson
This now happens in a new function, with the intent of having it invoked from our callbacks. This is one step on the way to 26009.
2018-05-03Merge remote-tracking branch 'github/ticket25952'Nick Mathewson
2018-05-03Merge remote-tracking branch 'github/ticket25951'Nick Mathewson
2018-05-03Merge remote-tracking branch 'github/ticket25949'Nick Mathewson
2018-05-02dirauth: Move authdir_mode_v3() to moduleDavid Goulet
This function must return false if the module is not compiled in. In order to do that, we move the authdir_mode_v3() function out of router.c and into the dirauth module new header file named mode.h. It is always returning false if we don't have the module. Closes #25990 Signed-off-by: David Goulet <dgoulet@torproject.org>
2018-05-01Merge remote-tracking branch 'github/eliminate_gettimeofday_cached'Nick Mathewson
2018-05-01Move unreachable port warnings to a periodic event.Nick Mathewson
Arguably, the conditions under which these events happen should be a bit different, but the rules are complex enough here that I've tried to have this commit be pure refactoring. Closes ticket 25952. Finally, before this code goes away, take a moment to look at the amazing way that we used to try to have an event happen every N seconds: get_uptime() / N != (get_uptime()+seconds_elapsed) / N Truly, it is a thing of wonder. I'm glad we didn't start using this pattern everywhere else.
2018-05-01Refactor to use safe_timer_diff.Nick Mathewson
2018-05-01Ensure that voting is rescheduled whenever the schedule changes.Nick Mathewson
2018-05-01Move responsibility for voting into a separate periodic callback.Nick Mathewson
Closes ticket25937.
2018-05-01Fix an assertion failure introduced by #25948Nick Mathewson
Apparently, we can decide our state is dirty before we create the event to tell the mainloop that we should save it. That's not a problem, except for the assertion failure.
2018-05-01Remove responsibility for flushing log cbs from mainloopNick Mathewson
This is now handled as-needed as the control module is flushing its own callbacks. Closes ticket 25951.
2018-05-01Merge remote-tracking branch 'dgoulet/ticket25610_034_01-squashed'Nick Mathewson
2018-04-30Add a cast to make clang happy.Nick Mathewson
2018-04-30Merge branch 'ticket25948_squashed'Nick Mathewson
2018-04-30Move responsibility for or_state_save() to a scheduled callbackNick Mathewson
Closes ticket 25948.
2018-04-30Merge remote-tracking branch 'dgoulet/ticket25900_034_01'Nick Mathewson
2018-04-27mod: Move dirauth specific files to its own moduleDavid Goulet
This is a pretty big commit but it only moves these files to src/or/dirauth: dircollate.c dirvote.c shared_random.c shared_random_state.c dircollate.h dirvote.h shared_random.h shared_random_state.h Then many files are modified to change the include line for those header files that have moved into a new directory. Without using --disable-module-dirauth, everything builds fine. When using the flag to disable the module, tor doesn't build due to linking errors. This will be addressed in the next commit(s). No code behavior change. Signed-off-by: David Goulet <dgoulet@torproject.org>
2018-04-27main: Don't rescan main loop events if not initializedDavid Goulet
This is done because it makes our life easier with unit tests. Also, a rescan on an uninitialized event list will result in a stacktrace. Signed-off-by: David Goulet <dgoulet@torproject.org>
2018-04-27Move responsibility for deferred SIGNEWNYM into a mainloop eventNick Mathewson
Closes ticket 25949.
2018-04-27Merge branch 'ticket25376_034_031_squashed'Nick Mathewson
2018-04-27hibernation: Rescan the event list on state changeDavid Goulet
When we change the hibernation state, rescan the main loop event list because the new state might affect the events. Signed-off-by: David Goulet <dgoulet@torproject.org>
2018-04-27main: Add mainloop callback event flagsDavid Goulet
Implement the ability to set flags per events which influences the set up of the event. This commit only adds one flag which is "need network" meaning that the event is not enabled if tor has disabled the network or if hibernation mode. Signed-off-by: David Goulet <dgoulet@torproject.org>
2018-04-26Merge branch 'ticket25933'Nick Mathewson
2018-04-26Fix a test assertion failure due to uninitialized mainloop eventsNick Mathewson
Bug not in any released Tor.
2018-04-26Merge branch 'ticket25931'Nick Mathewson
2018-04-26Remove connection_ap_attach_pending() from per-second callback.Nick Mathewson
In 25374, we created the necessary post-loop event for scheduling connection_ap_attach_pending as needed. Before that, we were already running this event once per mainloop. There's no reason to also run it once per second. Closes ticket 25933. No changes file, since the relevant change is already in 25374. Or possibly in 17590, depending on how you look at it.
2018-04-26Move close-and-cleanup functions to a postloop event.Nick Mathewson
Implements ticket 25932.
2018-04-26Move consdiffmgr_rescan() into a mainloop event.Nick Mathewson
The change here was very simple, since there is a flag set whenever we want to schedule this event. Closes ticket 25391. m
2018-04-26Rewrite time-handling in circuitmux_ewma to use monotime_coarseNick Mathewson
This part of the code was the only part that used "cached getttimeofday" feature, which wasn't monotonic, which we updated at slight expense, and which I'd rather not maintain.
2018-04-25callbacks: Add a DirServer roleDavid Goulet
The clean_consdiffmgr() callback is only for relays acting as a directory server, not all relays. This commit adds a role for only directory server and sets the clean_consdiffmgr() callback to use it. Signed-off-by: David Goulet <dgoulet@torproject.org>
2018-04-25clean_consdiffmgr() callback is only for directoriesDavid Goulet
Only relevant for directory servers. Signed-off-by: David Goulet <dgoulet@torproject.org>