[tor-commits] [tor/master] Merge branch 'messaging_v3' into messaging_v3_merged
asn at torproject.org
asn at torproject.org
Wed Mar 27 12:31:32 UTC 2019
commit a47b61f329fbe06b7b4935cf9c1923d96a74b649
Merge: 57999e330 3767eff9b
Author: Nick Mathewson <nickm at torproject.org>
Date: Tue Mar 26 20:13:49 2019 -0400
Merge branch 'messaging_v3' into messaging_v3_merged
.gitignore | 4 +
Makefile.am | 4 +
changes/pubsub | 5 +
doc/tor.1.txt | 2 +-
src/app/main/main.c | 179 ++-------
src/app/main/main.h | 3 -
src/app/main/ntmain.c | 1 +
src/app/main/shutdown.c | 192 ++++++++++
src/app/main/shutdown.h | 18 +
src/app/main/subsysmgr.c | 52 ++-
src/app/main/subsysmgr.h | 5 +
src/core/include.am | 4 +
src/core/mainloop/mainloop_pubsub.c | 170 +++++++++
src/core/mainloop/mainloop_pubsub.h | 24 ++
src/include.am | 2 +
src/lib/cc/compat_compiler.h | 12 +
src/lib/container/include.am | 3 +
src/lib/container/namemap.c | 184 ++++++++++
src/lib/container/namemap.h | 35 ++
src/lib/container/namemap_st.h | 34 ++
src/lib/dispatch/.may_include | 10 +
src/lib/dispatch/dispatch.h | 114 ++++++
src/lib/dispatch/dispatch_cfg.c | 141 ++++++++
src/lib/dispatch/dispatch_cfg.h | 39 ++
src/lib/dispatch/dispatch_cfg_st.h | 25 ++
src/lib/dispatch/dispatch_core.c | 260 +++++++++++++
src/lib/dispatch/dispatch_naming.c | 63 ++++
src/lib/dispatch/dispatch_naming.h | 46 +++
src/lib/dispatch/dispatch_new.c | 174 +++++++++
src/lib/dispatch/dispatch_st.h | 108 ++++++
src/lib/dispatch/include.am | 25 ++
src/lib/dispatch/msgtypes.h | 80 ++++
src/lib/log/log.c | 6 +-
src/lib/log/log.h | 22 +-
src/lib/pubsub/.may_include | 10 +
src/lib/pubsub/include.am | 26 ++
src/lib/pubsub/pub_binding_st.h | 38 ++
src/lib/pubsub/pubsub.h | 89 +++++
src/lib/pubsub/pubsub_build.c | 307 ++++++++++++++++
src/lib/pubsub/pubsub_build.h | 92 +++++
src/lib/pubsub/pubsub_builder_st.h | 161 +++++++++
src/lib/pubsub/pubsub_check.c | 428 ++++++++++++++++++++++
src/lib/pubsub/pubsub_connect.h | 54 +++
src/lib/pubsub/pubsub_flags.h | 32 ++
src/lib/pubsub/pubsub_macros.h | 373 +++++++++++++++++++
src/lib/pubsub/pubsub_publish.c | 72 ++++
src/lib/pubsub/pubsub_publish.h | 15 +
src/lib/smartlist_core/smartlist_core.c | 24 ++
src/lib/smartlist_core/smartlist_core.h | 1 +
src/lib/subsys/subsys.h | 4 +-
src/test/include.am | 4 +
src/test/test.c | 4 +
src/test/test.h | 4 +
src/test/test_containers.c | 61 ++++
src/test/test_dispatch.c | 249 +++++++++++++
src/test/test_namemap.c | 174 +++++++++
src/test/test_pubsub_build.c | 621 ++++++++++++++++++++++++++++++++
src/test/test_pubsub_msg.c | 305 ++++++++++++++++
58 files changed, 5033 insertions(+), 161 deletions(-)
diff --cc src/app/main/main.c
index 83eef0dc7,21e02f9ef..184b9e91d
--- a/src/app/main/main.c
+++ b/src/app/main/main.c
@@@ -38,14 -33,7 +33,9 @@@
#include "feature/api/tor_api.h"
#include "feature/api/tor_api_internal.h"
#include "feature/client/addressmap.h"
- #include "feature/client/bridges.h"
- #include "feature/client/entrynodes.h"
- #include "feature/client/transports.h"
#include "feature/control/control.h"
+#include "feature/control/control_auth.h"
+#include "feature/control/control_events.h"
- #include "feature/dirauth/bwauth.h"
#include "feature/dirauth/keypin.h"
#include "feature/dirauth/process_descs.h"
#include "feature/dircache/consdiffmgr.h"
diff --cc src/app/main/shutdown.c
index 000000000,a4e6cb088..314e33f22
mode 000000,100644..100644
--- a/src/app/main/shutdown.c
+++ b/src/app/main/shutdown.c
@@@ -1,0 -1,192 +1,192 @@@
+ /* Copyright (c) 2001 Matej Pfajfar.
+ * Copyright (c) 2001-2004, Roger Dingledine.
+ * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
+ * Copyright (c) 2007-2018, The Tor Project, Inc. */
+ /* See LICENSE for licensing information */
+
+ /**
+ * @file shutdown.c
+ * @brief Code to free global resources used by Tor.
+ *
+ * In the future, this should all be handled by the subsystem manager. */
+
+ #include "core/or/or.h"
+
+ #include "app/config/config.h"
+ #include "app/config/statefile.h"
+ #include "app/main/main.h"
+ #include "app/main/shutdown.h"
+ #include "app/main/subsysmgr.h"
+ #include "core/mainloop/connection.h"
+ #include "core/mainloop/mainloop.h"
+ #include "core/mainloop/mainloop_pubsub.h"
+ #include "core/or/channeltls.h"
+ #include "core/or/circuitlist.h"
+ #include "core/or/circuitmux_ewma.h"
+ #include "core/or/circuitpadding.h"
+ #include "core/or/connection_edge.h"
+ #include "core/or/dos.h"
+ #include "core/or/policies.h"
+ #include "core/or/protover.h"
+ #include "core/or/scheduler.h"
+ #include "core/or/versions.h"
+ #include "feature/client/addressmap.h"
+ #include "feature/client/bridges.h"
+ #include "feature/client/entrynodes.h"
+ #include "feature/client/transports.h"
+ #include "feature/control/control.h"
-#include "feature/control/control.h"
++#include "feature/control/control_auth.h"
+ #include "feature/dirauth/authmode.h"
+ #include "feature/dirauth/bwauth.h"
+ #include "feature/dirauth/dirvote.h"
+ #include "feature/dirauth/keypin.h"
+ #include "feature/dirauth/process_descs.h"
+ #include "feature/dirauth/shared_random.h"
+ #include "feature/dircache/consdiffmgr.h"
+ #include "feature/dircache/dirserv.h"
+ #include "feature/dirparse/routerparse.h"
+ #include "feature/hibernate/hibernate.h"
+ #include "feature/hs/hs_common.h"
+ #include "feature/nodelist/microdesc.h"
+ #include "feature/nodelist/networkstatus.h"
+ #include "feature/nodelist/nodelist.h"
+ #include "feature/nodelist/routerlist.h"
+ #include "feature/nodelist/routerlist.h"
+ #include "feature/relay/dns.h"
+ #include "feature/relay/ext_orport.h"
+ #include "feature/relay/onion_queue.h"
+ #include "feature/relay/routerkeys.h"
+ #include "feature/rend/rendcache.h"
+ #include "feature/rend/rendclient.h"
+ #include "feature/stats/geoip_stats.h"
+ #include "feature/stats/rephist.h"
+ #include "lib/evloop/compat_libevent.h"
+ #include "lib/geoip/geoip.h"
+ #include "src/feature/relay/router.h"
+
+ void evdns_shutdown(int);
+
+ /** Do whatever cleanup is necessary before shutting Tor down. */
+ void
+ tor_cleanup(void)
+ {
+ const or_options_t *options = get_options();
+ if (options->command == CMD_RUN_TOR) {
+ time_t now = time(NULL);
+ /* Remove our pid file. We don't care if there was an error when we
+ * unlink, nothing we could do about it anyways. */
+ tor_remove_file(options->PidFile);
+ /* Remove control port file */
+ tor_remove_file(options->ControlPortWriteToFile);
+ /* Remove cookie authentication file */
+ {
+ char *cookie_fname = get_controller_cookie_file_name();
+ tor_remove_file(cookie_fname);
+ tor_free(cookie_fname);
+ }
+ /* Remove Extended ORPort cookie authentication file */
+ {
+ char *cookie_fname = get_ext_or_auth_cookie_file_name();
+ tor_remove_file(cookie_fname);
+ tor_free(cookie_fname);
+ }
+ if (accounting_is_enabled(options))
+ accounting_record_bandwidth_usage(now, get_or_state());
+ or_state_mark_dirty(get_or_state(), 0); /* force an immediate save. */
+ or_state_save(now);
+ if (authdir_mode(options)) {
+ sr_save_and_cleanup();
+ }
+ if (authdir_mode_tests_reachability(options))
+ rep_hist_record_mtbf_data(now, 0);
+ keypin_close_journal();
+ }
+
+ timers_shutdown();
+
+ tor_free_all(0); /* We could move tor_free_all back into the ifdef below
+ later, if it makes shutdown unacceptably slow. But for
+ now, leave it here: it's helped us catch bugs in the
+ past. */
+ }
+
+ /** Free all memory that we might have allocated somewhere.
+ * If <b>postfork</b>, we are a worker process and we want to free
+ * only the parts of memory that we won't touch. If !<b>postfork</b>,
+ * Tor is shutting down and we should free everything.
+ *
+ * Helps us find the real leaks with sanitizers and the like. Also valgrind
+ * should then report 0 reachable in its leak report (in an ideal world --
+ * in practice libevent, SSL, libc etc never quite free everything). */
+ void
+ tor_free_all(int postfork)
+ {
+ if (!postfork) {
+ evdns_shutdown(1);
+ }
+ geoip_free_all();
+ geoip_stats_free_all();
+ dirvote_free_all();
+ routerlist_free_all();
+ networkstatus_free_all();
+ addressmap_free_all();
+ dirserv_free_fingerprint_list();
+ dirserv_free_all();
+ dirserv_clear_measured_bw_cache();
+ rend_cache_free_all();
+ rend_service_authorization_free_all();
+ rep_hist_free_all();
+ dns_free_all();
+ clear_pending_onions();
+ circuit_free_all();
+ circpad_machines_free();
+ entry_guards_free_all();
+ pt_free_all();
+ channel_tls_free_all();
+ channel_free_all();
+ connection_free_all();
+ connection_edge_free_all();
+ scheduler_free_all();
+ nodelist_free_all();
+ microdesc_free_all();
+ routerparse_free_all();
+ ext_orport_free_all();
+ control_free_all();
+ protover_free_all();
+ bridges_free_all();
+ consdiffmgr_free_all();
+ hs_free_all();
+ dos_free_all();
+ circuitmux_ewma_free_all();
+ accounting_free_all();
+ protover_summary_cache_free_all();
+
+ if (!postfork) {
+ config_free_all();
+ or_state_free_all();
+ router_free_all();
+ routerkeys_free_all();
+ policies_free_all();
+ }
+ if (!postfork) {
+ #ifndef _WIN32
+ tor_getpwnam(NULL);
+ #endif
+ }
+ /* stuff in main.c */
+
+ tor_mainloop_disconnect_pubsub();
+ tor_mainloop_free_all();
+
+ if (!postfork) {
+ release_lockfile();
+ }
+ tor_libevent_free_all();
+
+ subsystems_shutdown();
+
+ /* Stuff in util.c and address.c*/
+ if (!postfork) {
+ esc_router_info(NULL);
+ }
+ }
More information about the tor-commits
mailing list