Tor
0.4.7.0-alpha-dev
|
Header file for mainloop.c. More...
Go to the source code of this file.
Macros | |
#define | connection_add(conn) connection_add_impl((conn), 0) |
#define | connection_add_connecting(conn) connection_add_impl((conn), 1) |
Enumerations | |
enum | watchable_events_t { READ_EVENT =0x02 , WRITE_EVENT =0x04 } |
Variables | |
time_t | time_of_process_start |
struct token_bucket_rw_t | global_bucket |
struct token_bucket_rw_t | global_relayed_bucket |
Header file for mainloop.c.
Definition in file mainloop.h.
enum watchable_events_t |
Bitmask for events that we can turn on and off with connection_watch_events.
Enumerator | |
---|---|
READ_EVENT | We want to know when a connection is readable |
WRITE_EVENT | We want to know when a connection is writable |
Definition at line 35 of file mainloop.h.
void add_connection_to_closeable_list | ( | connection_t * | conn | ) |
Schedule conn to be closed.
Definition at line 424 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.
int connection_count_moribund | ( | void | ) |
Count moribund connections for the OOS handler
Definition at line 853 of file mainloop.c.
int connection_in_array | ( | connection_t * | conn | ) |
Return true iff conn is in the current poll array.
Definition at line 442 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 435 of file mainloop.c.
Referenced by connection_free_().
int connection_is_reading | ( | connection_t * | conn | ) |
Return true iff conn is listening for read events.
Definition at line 508 of file mainloop.c.
Referenced by set_streams_blocked_on_circ().
int connection_is_writing | ( | connection_t * | conn | ) |
Return true iff conn is listening for write events.
Definition at line 654 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 297 of file mainloop.c.
Referenced by connection_unlink().
void connection_start_reading | ( | connection_t * | conn | ) |
Tell the main loop to start notifying conn of any read events.
Definition at line 631 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_streams_blocked_on_circ().
void connection_start_writing | ( | connection_t * | conn | ) |
Tell the main loop to start notifying conn of any write events.
Definition at line 687 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 609 of file mainloop.c.
Referenced by connection_read_bw_exhausted(), connection_watch_events(), and set_streams_blocked_on_circ().
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 819 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 664 of file mainloop.c.
Referenced by connection_finished_flushing(), connection_watch_events(), and connection_write_bw_exhausted().
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 493 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 1097 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 1115 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 2320 of file mainloop.c.
int do_main_loop | ( | void | ) |
Tor main loop.
Definition at line 2346 of file mainloop.c.
void do_signewnym | ( | time_t | now | ) |
Either perform a signewnym or schedule one, depending on rate limiting.
Definition at line 1316 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 463 of file mainloop.c.
Referenced by control_get_bytes_rw_last_sec(), 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 473 of file mainloop.c.
Referenced by control_get_bytes_rw_last_sec(), 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 451 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 548 of file mainloop.c.
uint64_t get_main_loop_idle_count | ( | void | ) |
Get the main loop idle counter.
Definition at line 562 of file mainloop.c.
uint64_t get_main_loop_success_count | ( | void | ) |
Get the main loop success counter.
Definition at line 534 of file mainloop.c.
unsigned get_signewnym_epoch | ( | void | ) |
Return the number of times that signewnym has been called.
Definition at line 1340 of file mainloop.c.
long get_uptime | ( | void | ) |
Returns Tor's uptime.
Definition at line 2528 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().
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().
void initialize_mainloop_events | ( | void | ) |
Initialize some mainloop_event_t objects that we require.
Definition at line 2332 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 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 2289 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 1631 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 1656 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 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 1583 of file mainloop.c.
Referenced by hs_service_map_has_changed(), on_hibernate_state_change(), and rescan_periodic_events_cb().
void reschedule_directory_downloads | ( | void | ) |
Update our schedule so that we'll check whether we need to fetch directory info immediately.
Definition at line 1603 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 1907 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 1452 of file mainloop.c.
Referenced by circuit_note_clock_jumped().
void reset_main_loop_counters | ( | void | ) |
Reset our main loop counters.
Definition at line 518 of file mainloop.c.
void reset_uptime | ( | void | ) |
Reset Tor's uptime.
Definition at line 2535 of file mainloop.c.
Referenced by directory_all_unreachable().
void schedule_rescan_periodic_events | ( | void | ) |
Schedule an event that will rescan which periodic events should run.
Definition at line 1571 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 483 of file mainloop.c.
Referenced by record_num_bytes_transferred_impl().
int tor_event_loop_shutdown_is_pending | ( | void | ) |
Return true iff tor_shutdown_event_loop_and_exit() has been called.
Definition at line 792 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 412 of file mainloop.c.
Referenced by tor_init().
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 764 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 2197 of file mainloop.c.
Referenced by periodic_event_dispatch(), and signal_callback().
|
extern |
What time did this process start up?
Definition at line 142 of file mainloop.c.
Referenced by tor_init().