Tor 0.4.9.2-alpha-dev
|
Toplevel module. Handles signals, multiplexes between connections, implements main loop, and drives scheduled events. More...
#include "core/or/or.h"
#include "app/config/config.h"
#include "app/config/statefile.h"
#include "app/main/ntmain.h"
#include "core/mainloop/connection.h"
#include "core/mainloop/cpuworker.h"
#include "core/mainloop/mainloop.h"
#include "core/mainloop/netstatus.h"
#include "core/mainloop/periodic.h"
#include "core/or/channel.h"
#include "core/or/channelpadding.h"
#include "core/or/channeltls.h"
#include "core/or/circuitbuild.h"
#include "core/or/circuitlist.h"
#include "core/or/circuituse.h"
#include "core/or/connection_edge.h"
#include "core/or/connection_or.h"
#include "core/or/dos.h"
#include "core/or/status.h"
#include "feature/client/addressmap.h"
#include "feature/client/bridges.h"
#include "feature/client/dnsserv.h"
#include "feature/client/entrynodes.h"
#include "feature/client/proxymode.h"
#include "feature/client/transports.h"
#include "feature/control/control.h"
#include "feature/control/control_events.h"
#include "feature/dirauth/authmode.h"
#include "feature/dircache/consdiffmgr.h"
#include "feature/dirclient/dirclient_modes.h"
#include "feature/dircommon/directory.h"
#include "feature/hibernate/hibernate.h"
#include "feature/hs/hs_cache.h"
#include "feature/hs/hs_client.h"
#include "feature/hs/hs_service.h"
#include "feature/nodelist/microdesc.h"
#include "feature/nodelist/networkstatus.h"
#include "feature/nodelist/nodelist.h"
#include "feature/nodelist/routerlist.h"
#include "feature/relay/dns.h"
#include "feature/relay/routerkeys.h"
#include "feature/relay/routermode.h"
#include "feature/relay/selftest.h"
#include "feature/stats/geoip_stats.h"
#include "feature/stats/predict_ports.h"
#include "feature/stats/connstats.h"
#include "feature/stats/rephist.h"
#include "lib/buf/buffers.h"
#include "lib/crypt_ops/crypto_rand.h"
#include "lib/err/backtrace.h"
#include "lib/tls/buffers_tls.h"
#include "lib/net/buffers_net.h"
#include "lib/evloop/compat_libevent.h"
#include <event2/event.h>
#include "core/or/cell_st.h"
#include "core/or/entry_connection_st.h"
#include "feature/nodelist/networkstatus_st.h"
#include "core/or/or_connection_st.h"
#include "app/config/or_state_st.h"
#include "feature/nodelist/routerinfo_st.h"
#include "core/or/socks_request_st.h"
Go to the source code of this file.
Macros | |
#define | MAINLOOP_PRIVATE |
#define | MAX_SIGNEWNYM_RATE 10 |
#define | GREEDY_DESCRIPTOR_RETRY_INTERVAL (10) |
#define | LAZY_DESCRIPTOR_RETRY_INTERVAL (60) |
#define | CALLBACK(name) static int name ## _callback(time_t, const or_options_t *) |
#define | CALLBACK(name, r, f) PERIODIC_EVENT(name, PERIODIC_EVENT_ROLE_ ## r, f) |
#define | FL(name) (PERIODIC_EVENT_FLAG_ ## name) |
#define | NAMED_CALLBACK(name) STMT_BEGIN name ## _event = periodic_events_find( #name ); STMT_END |
#define | VANGUARDS_LITE_INTERVAL (15*60) |
#define | ENTROPY_INTERVAL (60*60) |
#define | CHECK_PARTICIPATION_INTERVAL (5*60) |
#define | CHECK_EXPIRED_NS_INTERVAL (2*60) |
#define | CHECK_WRITE_STATS_INTERVAL (60*60) |
#define | CLEAN_CACHES_INTERVAL (30*60) |
#define | ROUTERLIST_PRUNING_INTERVAL (60*60) |
#define | CDM_CLEAN_CALLBACK_INTERVAL 600 |
#define | NUM_JUMPED_SECONDS_BEFORE_NETSTATUS_UPDATE 20 |
#define | NUM_JUMPED_SECONDS_BEFORE_WARN 100 |
#define | NUM_IDLE_SECONDS_BEFORE_WARN 3600 |
#define | UPTIME_CUTOFF_FOR_NEW_BANDWIDTH_TEST (6*60*60) |
Toplevel module. Handles signals, multiplexes between connections, implements main loop, and drives scheduled events.
For the main loop itself; see run_main_loop_once(). It invokes the rest of Tor mostly through Libevent callbacks. Libevent callbacks can happen when a timer elapses, a signal is received, a socket is ready to read or write, or an event is manually activated.
Most events in Tor are driven from these callbacks:
Other events are used for specific purposes, or for building more complex control structures. If you search for usage of tor_event_new(), you will find all the events that we construct in Tor.
Tor has numerous housekeeping operations that need to happen regularly. They are handled in different ways:
The most frequent operations are handled after every read or write event, at the end of connection_handle_read() and connection_handle_write().
The next most frequent operations happen after each invocation of the main loop, in run_main_loop_once().
Once per second, we run all of the operations listed in second_elapsed_callback(), and in its child, run_scheduled_events().
Once-a-second operations are handled in second_elapsed_callback().
Definition in file mainloop.c.
#define CALLBACK | ( | name | ) | static int name ## _callback(time_t, const or_options_t *) |
Definition at line 1388 of file mainloop.c.
#define CALLBACK | ( | name, | |
r, | |||
f | |||
) | PERIODIC_EVENT(name, PERIODIC_EVENT_ROLE_ ## r, f) |
Definition at line 1388 of file mainloop.c.
#define CDM_CLEAN_CALLBACK_INTERVAL 600 |
Definition at line 2165 of file mainloop.c.
Definition at line 1390 of file mainloop.c.
#define GREEDY_DESCRIPTOR_RETRY_INTERVAL (10) |
How often do we check for router descriptors that we should download when we have too little directory info?
Definition at line 194 of file mainloop.c.
#define LAZY_DESCRIPTOR_RETRY_INTERVAL (60) |
How often do we check for router descriptors that we should download when we have enough directory info?
Definition at line 197 of file mainloop.c.
#define MAINLOOP_PRIVATE |
Definition at line 49 of file mainloop.c.
#define MAX_SIGNEWNYM_RATE 10 |
How often will we honor SIGNEWNYM requests?
Definition at line 153 of file mainloop.c.
#define UPTIME_CUTOFF_FOR_NEW_BANDWIDTH_TEST (6*60*60) |
Definition at line 2305 of file mainloop.c.
void add_connection_to_closeable_list | ( | connection_t * | conn | ) |
Schedule conn to be closed.
Definition at line 416 of file mainloop.c.
|
static |
Periodic callback: once an hour, grab some more entropy from the kernel and feed it to our CSPRNG.
How often do we add more entropy to OpenSSL's RNG pool?
Definition at line 1827 of file mainloop.c.
|
static |
Periodic callback: If our consensus is too old, recalculate whether we can actually use it.
Definition at line 1902 of file mainloop.c.
STATIC int check_network_participation_callback | ( | time_t | now, |
const or_options_t * | options | ||
) |
Periodic callback: if there has been no network usage in a while, enter a dormant state.
How often do we check whether we have had network activity?
Definition at line 1845 of file mainloop.c.
|
static |
Periodic callback: Clean in-memory caches every once in a while
Definition at line 2044 of file mainloop.c.
|
static |
Definition at line 2167 of file mainloop.c.
STATIC void close_closeable_connections | ( | void | ) |
Close all connections that have been scheduled to get closed.
Definition at line 846 of file mainloop.c.
Referenced by postloop_cleanup_cb().
|
static |
If the connection at connection_array[i] is marked for close, then:
Definition at line 966 of file mainloop.c.
|
static |
Libevent callback: this gets invoked when (connection_t*)conn has some data to read.
Definition at line 880 of file mainloop.c.
|
static |
Libevent callback: this gets invoked when (connection_t*)conn has some data to write.
Definition at line 922 of file mainloop.c.
int connection_add_impl | ( | connection_t * | conn, |
int | is_connecting | ||
) |
Add conn to the array of connections that we can poll on. The connection's socket must be set; the connection starts out non-reading and non-writing.
Definition at line 244 of file mainloop.c.
|
static |
Check whether conn is correct in having (or not having) a read/write event (passed in ev). On success, return 0. On failure, log a warning and return -1.
Definition at line 563 of file mainloop.c.
Referenced by connection_start_reading(), connection_start_writing(), connection_stop_reading(), and connection_stop_writing().
int connection_count_moribund | ( | void | ) |
Count moribund connections for the OOS handler
Definition at line 862 of file mainloop.c.
int connection_in_array | ( | connection_t * | conn | ) |
Return true iff conn is in the current poll array.
Definition at line 434 of file mainloop.c.
Referenced by connection_free_().
int connection_is_on_closeable_list | ( | connection_t * | conn | ) |
Return 1 if conn is on the closeable list, else return 0.
Definition at line 427 of file mainloop.c.
Referenced by connection_free_().
int connection_is_reading | ( | const connection_t * | conn | ) |
Return true iff conn is listening for read events.
Definition at line 500 of file mainloop.c.
Referenced by set_block_state_for_streams().
int connection_is_writing | ( | connection_t * | conn | ) |
Return true iff conn is listening for write events.
Definition at line 663 of file mainloop.c.
int connection_remove | ( | connection_t * | conn | ) |
Remove the connection from the global list, and remove the corresponding poll entry. Calling this function will shift the last connection (if any) into the position occupied by conn.
Definition at line 289 of file mainloop.c.
Referenced by connection_unlink().
|
static |
Return true iff conn is linked conn, and reading from the conn linked to it would be good and feasible. (Reading is "feasible" if the other conn exists and has data in its outbuf, and is "good" if we have our reading_from_linked_conn flag set and the other conn has its writing_to_linked_conn flag set.)
Definition at line 724 of file mainloop.c.
Referenced by connection_start_reading(), and connection_start_writing().
void connection_start_reading | ( | connection_t * | conn | ) |
Tell the main loop to start notifying conn of any read events.
Definition at line 623 of file mainloop.c.
Referenced by circuit_resume_edge_reading_helper(), connection_ext_or_finished_flushing(), connection_init_accepted_conn(), connection_unlink(), connection_watch_events(), reenable_blocked_connections_cb(), and set_block_state_for_streams().
|
static |
Helper: Tell the main loop to begin reading bytes into conn from its linked connection, if it is not doing so already. Called by connection_start_reading and connection_start_writing as appropriate.
Definition at line 810 of file mainloop.c.
Referenced by connection_start_reading(), and connection_start_writing().
void connection_start_writing | ( | connection_t * | conn | ) |
Tell the main loop to start notifying conn of any write events.
Definition at line 696 of file mainloop.c.
Referenced by connection_watch_events(), connection_write_to_buf_commit(), and reenable_blocked_connections_cb().
void connection_stop_reading | ( | connection_t * | conn | ) |
Tell the main loop to stop notifying conn of any read events.
Definition at line 601 of file mainloop.c.
Referenced by connection_read_bw_exhausted(), connection_watch_events(), and set_block_state_for_streams().
void connection_stop_reading_from_linked_conn | ( | connection_t * | conn | ) |
Tell the main loop to stop reading bytes into conn from its linked connection, if is currently doing so. Called by connection_stop_reading, connection_stop_writing, and connection_read.
Definition at line 828 of file mainloop.c.
Referenced by connection_stop_reading(), and connection_stop_writing().
void connection_stop_writing | ( | connection_t * | conn | ) |
Tell the main loop to stop notifying conn of any write events.
Definition at line 673 of file mainloop.c.
Referenced by connection_finished_flushing(), connection_watch_events(), and connection_write_bw_exhausted().
|
static |
If conn is an edge conn, remove it from the list of conn's on this circuit. If it's not on an edge, flush and send destroys for all circuits on this conn.
Remove it from connection_array (if applicable) and from closeable_connection_list.
Then free it.
Definition at line 332 of file mainloop.c.
void connection_unregister_events | ( | connection_t * | conn | ) |
Tell libevent that we don't care about conn any more.
Definition at line 275 of file mainloop.c.
void connection_watch_events | ( | connection_t * | conn, |
watchable_events_t | events | ||
) |
Set the event mask on conn to events. (The event mask is a bitmask whose bits are READ_EVENT and WRITE_EVENT)
Definition at line 485 of file mainloop.c.
|
static |
Definition at line 2205 of file mainloop.c.
void directory_all_unreachable | ( | time_t | now | ) |
We've just tried every dirserver we know about, and none of them were reachable. Assume the network is down. Change state so next time an application connection arrives we'll delay it and try another directory fetch. Kill off all the circuit_wait streams that are waiting now, since they will all timeout anyway.
Definition at line 1106 of file mainloop.c.
|
static |
Implementation for directory_all_unreachable. This is done in a callback, since otherwise it would complicate Tor's control-flow graph beyond all reason.
Definition at line 1076 of file mainloop.c.
void directory_info_has_arrived | ( | time_t | now, |
int | from_cache, | ||
int | suppress_logs | ||
) |
This function is called whenever we successfully pull down some new network statuses or server descriptors.
Definition at line 1124 of file mainloop.c.
void dns_servers_relaunch_checks | ( | void | ) |
Forget what we've learned about the correctness of our DNS servers, and start learning again.
Definition at line 2349 of file mainloop.c.
int do_main_loop | ( | void | ) |
Tor main loop.
Definition at line 2375 of file mainloop.c.
void do_signewnym | ( | time_t | now | ) |
Either perform a signewnym or schedule one, depending on rate limiting.
Definition at line 1326 of file mainloop.c.
|
static |
Periodic event: once a minute, (or every second if TestingTorNetwork, or during client bootstrap), check whether we want to download any networkstatus documents.
Definition at line 2096 of file mainloop.c.
uint64_t get_bytes_read | ( | void | ) |
Return the amount of network traffic read, in bytes, over the life of this process.
Definition at line 455 of file mainloop.c.
Referenced by control_get_bytes_rw_last_sec(), fill_traffic_values(), and log_heartbeat().
uint64_t get_bytes_written | ( | void | ) |
Return the amount of network traffic read, in bytes, over the life of this process.
Definition at line 465 of file mainloop.c.
Referenced by control_get_bytes_rw_last_sec(), fill_traffic_values(), and log_heartbeat().
smartlist_t * get_connection_array | ( | void | ) |
Set *array to an array of all connections. *array must not be modified.
Definition at line 443 of file mainloop.c.
Referenced by circuit_discard_optional_exit_enclaves(), circuits_handle_oom(), connection_ap_expire_beginning(), connection_ap_fail_onehop(), connection_ap_rescan_and_attach_pending(), connection_expire_held_open(), connection_free_all(), connection_mark_all_noncontrol_connections(), connection_mark_all_noncontrol_listeners(), connection_or_clear_identity_map(), control_event_conn_bandwidth_used(), control_event_stream_bandwidth_used(), control_ports_write_to_file(), control_update_global_event_mask(), dumpstats(), list_pending_downloads(), list_pending_fpsk_downloads(), options_act_relay_bandwidth(), reenable_blocked_connections_cb(), retry_all_listeners(), and router_get_active_listener_port_by_type_af().
uint64_t get_main_loop_error_count | ( | void | ) |
Get the main loop error counter.
Definition at line 540 of file mainloop.c.
uint64_t get_main_loop_idle_count | ( | void | ) |
Get the main loop idle counter.
Definition at line 554 of file mainloop.c.
uint64_t get_main_loop_success_count | ( | void | ) |
Get the main loop success counter.
Definition at line 526 of file mainloop.c.
STATIC int get_my_roles | ( | const or_options_t * | options | ) |
Return a bitmask of the roles this tor instance is configured for using the given options.
Definition at line 1474 of file mainloop.c.
Referenced by rescan_periodic_events().
unsigned get_signewnym_epoch | ( | void | ) |
Return the number of times that signewnym has been called.
Definition at line 1350 of file mainloop.c.
long get_uptime | ( | void | ) |
Returns Tor's uptime.
Definition at line 2557 of file mainloop.c.
Referenced by check_descriptor_bandwidth_changed(), check_for_reachability_bw_callback(), dirserv_thinks_router_is_hs_dir(), log_heartbeat(), and reachability_warnings_callback().
|
static |
Callback: run a deferred signewnym.
Definition at line 1316 of file mainloop.c.
Referenced by do_signewnym().
int have_completed_a_circuit | ( | void | ) |
Return 1 if we have successfully built a circuit, and nothing has changed to make us think that maybe we can't.
Definition at line 218 of file mainloop.c.
Referenced by check_for_reachability_bw_callback(), directory_info_has_arrived(), and reachability_warnings_callback().
|
static |
Periodic callback: write the heartbeat message in the logs.
If writing the heartbeat message to the logs fails for some reason, retry again after MIN_HEARTBEAT_PERIOD seconds.
Definition at line 2142 of file mainloop.c.
|
static |
Definition at line 2181 of file mainloop.c.
|
static |
Increment the main loop error counter.
Definition at line 533 of file mainloop.c.
|
static |
Increment the main loop idle counter.
Definition at line 547 of file mainloop.c.
|
static |
Increment the main loop success counter.
Definition at line 519 of file mainloop.c.
void initialize_mainloop_events | ( | void | ) |
Initialize some mainloop_event_t objects that we require.
Definition at line 2361 of file mainloop.c.
Referenced by do_main_loop().
void initialize_periodic_events | ( | void | ) |
Set up all the members of mainloop_periodic_events[], and configure them all to be launched from a callback.
Definition at line 1533 of file mainloop.c.
|
static |
Helper, run one second after setup: Initializes all members of periodic_events and starts them running.
(We do this one second after setup for backward-compatibility reasons; it might not actually be necessary.)
Definition at line 1519 of file mainloop.c.
void ip_address_changed | ( | int | on_client_conn | ) |
Called when our IP address seems to have changed. on_client_conn should be true if:
Definition at line 2318 of file mainloop.c.
|
static |
Periodic callback: Every {LAZY,GREEDY}_DESCRIPTOR_RETRY_INTERVAL, see about fetching descriptors, microdescriptors, and extrainfo documents.
Definition at line 1775 of file mainloop.c.
void mainloop_schedule_postloop_cleanup | ( | void | ) |
Schedule a post-loop event to clean up marked channels, connections, and circuits.
Definition at line 1645 of file mainloop.c.
Referenced by add_connection_to_closeable_list().
void mainloop_schedule_shutdown | ( | int | delay_sec | ) |
Schedule the mainloop to exit after delay_sec seconds.
Definition at line 1670 of file mainloop.c.
|
static |
Update vanguards-lite layer2 nodes, once every 15 minutes
Definition at line 1683 of file mainloop.c.
void note_that_we_completed_a_circuit | ( | void | ) |
Note that we have successfully built a circuit, so that reachability testing and introduction points and so on may be attempted.
Definition at line 226 of file mainloop.c.
void note_that_we_maybe_cant_complete_circuits | ( | void | ) |
Note that something has happened (like a clock jump, or DisableNetwork) to make us think that maybe we can't complete circuits.
Definition at line 234 of file mainloop.c.
Referenced by circuit_note_clock_jumped().
void periodic_events_on_new_options | ( | const or_options_t * | options | ) |
Definition at line 1607 of file mainloop.c.
|
static |
Mainloop callback: clean up circuits, channels, and connections that are pending close.
Definition at line 1629 of file mainloop.c.
Referenced by initialize_mainloop_events().
|
static |
Periodic callback: prune routerlist of old information about Tor network.
Definition at line 2074 of file mainloop.c.
|
static |
Periodic callback: Write bridge statistics to disk if appropriate.
Definition at line 2016 of file mainloop.c.
|
static |
Periodic callback: Clean the cache of failed hidden service lookups frequently.
Definition at line 2060 of file mainloop.c.
void rescan_periodic_events | ( | const or_options_t * | options | ) |
Do a pass at all our periodic events, disable those we don't need anymore and enable those we need now using the given options.
Definition at line 1597 of file mainloop.c.
Referenced by hs_service_map_has_changed(), on_hibernate_state_change(), and rescan_periodic_events_cb().
|
static |
Callback: rescan the periodic event list.
Definition at line 1574 of file mainloop.c.
void reschedule_directory_downloads | ( | void | ) |
Update our schedule so that we'll check whether we need to fetch directory info immediately.
Definition at line 1617 of file mainloop.c.
void reschedule_or_state_save | ( | void | ) |
Reschedule the event for saving the state file.
Run this when the state becomes dirty.
Definition at line 1936 of file mainloop.c.
Referenced by or_state_mark_dirty().
void reset_all_main_loop_timers | ( | void | ) |
Reset all the periodic events so we'll do all our actions again as if we just started up. Useful if our clock just moved back a long time from the future, so we don't wait until that future arrives again before acting.
Definition at line 1466 of file mainloop.c.
Referenced by circuit_note_clock_jumped().
void reset_main_loop_counters | ( | void | ) |
Reset our main loop counters.
Definition at line 510 of file mainloop.c.
|
static |
Definition at line 2000 of file mainloop.c.
void reset_uptime | ( | void | ) |
Reset Tor's uptime.
Definition at line 2564 of file mainloop.c.
Referenced by directory_all_unreachable().
|
static |
Periodic callback: Every 60 seconds, we relaunch listeners if any died.
Definition at line 2122 of file mainloop.c.
|
static |
Periodic event: Rotate our X.509 certificates and TLS keys once every MAX_SSL_KEY_LIFETIME_INTERNAL.
Definition at line 1793 of file mainloop.c.
|
static |
Perform regular maintenance tasks for a single connection. This function gets run once per second per connection by run_scheduled_events.
Definition at line 1165 of file mainloop.c.
|
static |
Run the main loop a single time. Return 0 for "exit"; -1 for "exit with error", and 1 for "run this again."
Definition at line 2450 of file mainloop.c.
Referenced by run_main_loop_until_done().
STATIC int run_main_loop_until_done | ( | void | ) |
Run the run_main_loop_once() function until it declares itself done, and return its final return value.
Shadow won't invoke this function, so don't fill it up with things.
Definition at line 2538 of file mainloop.c.
|
static |
Scheduled callback: Save the state file to disk if appropriate.
Definition at line 1921 of file mainloop.c.
|
static |
Callback: used to activate read events for all linked connections, so libevent knows to call their read callbacks. This callback run as a postloop event, so that the events it activates don't happen until Libevent has a chance to check for other events.
Definition at line 379 of file mainloop.c.
Referenced by initialize_mainloop_events().
void schedule_rescan_periodic_events | ( | void | ) |
Schedule an event that will rescan which periodic events should run.
Definition at line 1585 of file mainloop.c.
|
static |
Callback: run a scheduled shutdown
Definition at line 1660 of file mainloop.c.
Referenced by mainloop_schedule_shutdown().
|
static |
Perform regular maintenance tasks. This function gets run once per second.
Definition at line 1698 of file mainloop.c.
|
static |
Failsafe measure that should never actually be necessary: If tor_shutdown_event_loop_and_exit() somehow doesn't successfully exit the event loop, then this callback will kill Tor with an assertion failure seconds later
Definition at line 744 of file mainloop.c.
|
static |
Honor a NEWNYM request: make future requests unlinkable to past requests.
Definition at line 1293 of file mainloop.c.
void stats_increment_bytes_read_and_written | ( | uint64_t | r, |
uint64_t | w | ||
) |
Increment the amount of network traffic read and written, over the life of this process.
Definition at line 475 of file mainloop.c.
Referenced by record_num_bytes_transferred_impl().
STATIC void teardown_periodic_events | ( | void | ) |
Definition at line 1559 of file mainloop.c.
int tor_event_loop_shutdown_is_pending | ( | void | ) |
Return true iff tor_shutdown_event_loop_and_exit() has been called.
Definition at line 801 of file mainloop.c.
Referenced by set_options().
void tor_init_connection_lists | ( | void | ) |
Initialize the global connection list, closeable connection list, and active connection list.
Definition at line 404 of file mainloop.c.
Referenced by tor_init().
void tor_mainloop_free_all | ( | void | ) |
Definition at line 2570 of file mainloop.c.
void tor_shutdown_event_loop_and_exit | ( | int | exitcode | ) |
After finishing the current callback (if any), shut down the main loop, clean up the process, and exit with exitcode.
Definition at line 773 of file mainloop.c.
void update_current_time | ( | time_t | now | ) |
Set the current time to "now", which should be the value returned by time(). Check for clock jumps and track the total number of seconds we have been running.
How much clock jumping means that we should adjust our idea of when to go dormant?
How much clock jumping do we tolerate?
How much idleness do we tolerate?
Definition at line 2226 of file mainloop.c.
Referenced by periodic_event_dispatch(), and signal_callback().
|
static |
Periodic callback: Write statistics to disk if appropriate.
Definition at line 1949 of file mainloop.c.
|
static |
List of linked connections that are currently reading data into their inbuf from their partner's outbuf.
Definition at line 170 of file mainloop.c.
Referenced by connection_start_reading_from_linked_conn(), connection_stop_reading_from_linked_conn(), connection_unlink(), schedule_active_linked_connections_cb(), and tor_init_connection_lists().
|
static |
Flag: Set to true iff we entered the current libevent main loop via loop_once. If so, there's no need to trigger a loopexit in order to handle linked connections.
Definition at line 174 of file mainloop.c.
|
static |
We set this to 1 when we've opened a circuit, so we can print a log entry to inform the user that Tor is working. We set it to 0 when we think the fact that we once opened a circuit doesn't mean we can do so any longer (a big time jump happened, when we notice our directory is heinously out-of-date, etc.
Definition at line 190 of file mainloop.c.
Referenced by have_completed_a_circuit(), note_that_we_completed_a_circuit(), and note_that_we_maybe_cant_complete_circuits().
|
static |
Definition at line 1456 of file mainloop.c.
|
static |
List of connections that have been marked for close and need to be freed and removed from connection_array.
Definition at line 167 of file mainloop.c.
Referenced by add_connection_to_closeable_list(), connection_count_moribund(), connection_is_on_closeable_list(), connection_unlink(), and tor_init_connection_lists().
STATIC smartlist_t* connection_array = NULL |
Smartlist of all open connections.
Definition at line 164 of file mainloop.c.
Referenced by circuits_handle_oom(), connection_in_array(), get_connection_array(), and tor_init_connection_lists().
|
static |
Last time that update_current_time was called.
Definition at line 2216 of file mainloop.c.
Referenced by channel_tls_handle_var_cell(), and command_process_cell().
|
static |
Last time that update_current_time updated current_second.
Definition at line 2218 of file mainloop.c.
|
static |
Definition at line 1097 of file mainloop.c.
|
static |
Definition at line 1454 of file mainloop.c.
token_bucket_rw_t global_bucket |
Definition at line 131 of file mainloop.c.
token_bucket_rw_t global_relayed_bucket |
Definition at line 134 of file mainloop.c.
|
static |
Mainloop event for the deferred signewnym call.
Definition at line 159 of file mainloop.c.
Referenced by do_signewnym().
|
static |
Definition at line 2133 of file mainloop.c.
|
static |
Event to run initialize_periodic_events_cb
Definition at line 1511 of file mainloop.c.
Referenced by do_main_loop().
|
static |
Definition at line 1455 of file mainloop.c.
|
static |
Rate-limiter for EINVAL-type libevent warnings.
Definition at line 2442 of file mainloop.c.
|
static |
The return value that the main loop should yield when it exits, if main_loop_should_exit is true.
Definition at line 182 of file mainloop.c.
Referenced by run_main_loop_until_done(), and tor_shutdown_event_loop_and_exit().
|
static |
Flag: if true, it's time to shut down, so the main loop should exit as soon as possible.
Definition at line 178 of file mainloop.c.
Referenced by run_main_loop_until_done(), tor_event_loop_shutdown_is_pending(), and tor_shutdown_event_loop_and_exit().
STATIC periodic_event_item_t mainloop_periodic_events[] |
Definition at line 1393 of file mainloop.c.
|
static |
How many times have we called newnym?
Definition at line 161 of file mainloop.c.
Referenced by get_signewnym_epoch().
|
static |
True iff we have initialized all the members of periodic_events. Used to prevent double-initialization.
Definition at line 1357 of file mainloop.c.
Referenced by do_main_loop(), and initialize_periodic_events().
|
static |
Event to run postloop_cleanup_cb
Definition at line 1640 of file mainloop.c.
Referenced by initialize_mainloop_events().
|
static |
Definition at line 1458 of file mainloop.c.
|
static |
Definition at line 1570 of file mainloop.c.
|
static |
Definition at line 1457 of file mainloop.c.
|
static |
Event that invokes schedule_active_linked_connections_cb.
Definition at line 370 of file mainloop.c.
Referenced by connection_start_reading_from_linked_conn(), and initialize_mainloop_events().
|
static |
Event to run 'scheduled_shutdown_cb'
Definition at line 1656 of file mainloop.c.
Referenced by mainloop_schedule_shutdown().
|
static |
Definition at line 2010 of file mainloop.c.
|
static |
Event to run 'shutdown did not work callback'.
Definition at line 736 of file mainloop.c.
Referenced by tor_shutdown_event_loop_and_exit().
|
static |
Is there a signewnym request we're currently waiting to handle?
Definition at line 157 of file mainloop.c.
Referenced by do_signewnym().
|
static |
How many bytes have we read since we started the process?
Definition at line 138 of file mainloop.c.
Referenced by control_get_bytes_rw_last_sec(), get_bytes_read(), and stats_increment_bytes_read_and_written().
|
static |
How many bytes have we written since we started the process?
Definition at line 140 of file mainloop.c.
Referenced by control_get_bytes_rw_last_sec(), get_bytes_written(), and stats_increment_bytes_read_and_written().
|
static |
How many times have we received an error from the main loop?
Definition at line 148 of file mainloop.c.
Referenced by get_main_loop_error_count(), increment_main_loop_error_count(), and reset_main_loop_counters().
|
static |
How many times have we returned from the main loop with no events.
Definition at line 150 of file mainloop.c.
Referenced by get_main_loop_idle_count(), increment_main_loop_idle_count(), and reset_main_loop_counters().
|
static |
How many times have we returned from the main loop successfully?
Definition at line 146 of file mainloop.c.
Referenced by get_main_loop_success_count(), increment_main_loop_success_count(), and reset_main_loop_counters().
|
static |
How many seconds have we been running?
Definition at line 144 of file mainloop.c.
Referenced by get_uptime(), and reset_uptime().
|
static |
When did we last process a SIGNEWNYM request?
Definition at line 155 of file mainloop.c.
Referenced by do_signewnym().
time_t time_of_process_start = 0 |
What time did this process start up?
Definition at line 142 of file mainloop.c.
Referenced by tor_init().