[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor/master] Merge branch 'orconn-tracker_squashed'
commit 70dd6d07bbd7c233e9f39e24b27775eae77f2363
Merge: fd58e5e49 2100b35f0
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date: Fri Dec 21 14:22:11 2018 -0500
Merge branch 'orconn-tracker_squashed'
changes/ticket27167 | 11 ++
doc/tor.1.txt | 2 +-
src/app/main/subsystem_list.c | 7 +
src/core/include.am | 16 +++
src/core/mainloop/connection.c | 2 +-
src/core/or/channeltls.c | 3 -
src/core/or/channeltls.h | 1 -
src/core/or/circuitbuild.c | 32 ++++-
src/core/or/circuitlist.c | 57 +++++++-
src/core/or/circuitlist.h | 3 +
src/core/or/circuitstats.c | 6 +-
src/core/or/circuituse.c | 2 +-
src/core/or/connection_or.c | 81 ++++++++---
src/core/or/connection_or.h | 30 +---
src/core/or/ocirc_event.c | 84 +++++++++++
src/core/or/ocirc_event.h | 89 ++++++++++++
src/core/or/ocirc_event_sys.h | 13 ++
src/core/or/orconn_event.c | 81 +++++++++++
src/core/or/orconn_event.h | 120 ++++++++++++++++
src/core/or/orconn_event_sys.h | 12 ++
src/feature/control/btrack.c | 53 +++++++
src/feature/control/btrack_circuit.c | 164 +++++++++++++++++++++
src/feature/control/btrack_circuit.h | 15 ++
src/feature/control/btrack_orconn.c | 206 ++++++++++++++++++++++++++
src/feature/control/btrack_orconn.h | 38 +++++
src/feature/control/btrack_orconn_cevent.c | 159 ++++++++++++++++++++
src/feature/control/btrack_orconn_cevent.h | 17 +++
src/feature/control/btrack_orconn_maps.c | 223 +++++++++++++++++++++++++++++
src/feature/control/btrack_orconn_maps.h | 17 +++
src/feature/control/btrack_sys.h | 14 ++
src/feature/control/control.c | 5 +-
src/feature/control/control.h | 64 +++++----
src/feature/control/control_bootstrap.c | 59 +++++---
src/feature/nodelist/nodelist.c | 4 +-
src/feature/relay/ext_orport.c | 2 +-
src/lib/log/log.c | 2 +-
src/lib/log/log.h | 4 +-
src/test/include.am | 1 +
src/test/test.c | 1 +
src/test/test.h | 1 +
src/test/test_btrack.c | 100 +++++++++++++
src/test/test_controller_events.c | 163 +++++++++++++++++++--
42 files changed, 1845 insertions(+), 119 deletions(-)
diff --cc src/app/main/subsystem_list.c
index bd6be4214,2f2586ac1..9f9bf1086
--- a/src/app/main/subsystem_list.c
+++ b/src/app/main/subsystem_list.c
@@@ -36,7 -38,9 +39,11 @@@ const subsys_fns_t *tor_subsystems[] =
&sys_compress, /* -70 */
&sys_crypto, /* -60 */
&sys_tortls, /* -50 */
- &sys_orconn_event, /* -40 */
- &sys_ocirc_event, /* -39 */
+ &sys_process, /* -35 */
++
++ &sys_orconn_event, /* -33 */
++ &sys_ocirc_event, /* -32 */
+ &sys_btrack, /* -30 */
};
const unsigned n_tor_subsystems = ARRAY_LENGTH(tor_subsystems);
diff --cc src/core/or/ocirc_event.c
index 000000000,f9f8af279..b400022bb
mode 000000,100644..100644
--- a/src/core/or/ocirc_event.c
+++ b/src/core/or/ocirc_event.c
@@@ -1,0 -1,84 +1,84 @@@
+ /* Copyright (c) 2007-2018, The Tor Project, Inc. */
+ /* See LICENSE for licensing information */
+
+ /**
+ * \file ocirc_event.c
+ * \brief Publish state change messages for origin circuits
+ *
+ * Implements a basic publish-subscribe framework for messages about
+ * the state of origin circuits. The publisher calls the subscriber
+ * callback functions synchronously.
+ *
+ * Although the synchronous calls might not simplify the call graph,
+ * this approach improves data isolation because the publisher doesn't
+ * need knowledge about the internals of subscribing subsystems. It
+ * also avoids race conditions that might occur in asynchronous
+ * frameworks.
+ **/
+
+ #include "core/or/or.h"
+
+ #define OCIRC_EVENT_PRIVATE
+
+ #include "core/or/cpath_build_state_st.h"
+ #include "core/or/ocirc_event.h"
+ #include "core/or/ocirc_event_sys.h"
+ #include "core/or/origin_circuit_st.h"
+ #include "lib/subsys/subsys.h"
+
+ /** List of subscribers */
+ static smartlist_t *ocirc_event_rcvrs;
+
+ /** Initialize subscriber list */
+ static int
+ ocirc_event_init(void)
+ {
+ ocirc_event_rcvrs = smartlist_new();
+ return 0;
+ }
+
+ /** Free subscriber list */
+ static void
+ ocirc_event_fini(void)
+ {
+ smartlist_free(ocirc_event_rcvrs);
+ }
+
+ /**
+ * Subscribe to messages about origin circuit events
+ *
+ * Register a callback function to receive messages about origin
+ * circuits. The publisher calls this function synchronously.
+ **/
+ void
+ ocirc_event_subscribe(ocirc_event_rcvr_t fn)
+ {
+ tor_assert(fn);
+ /* Don't duplicate subscriptions. */
+ if (smartlist_contains(ocirc_event_rcvrs, fn))
+ return;
+
+ smartlist_add(ocirc_event_rcvrs, fn);
+ }
+
+ /**
+ * Publish a message about OR connection events
+ *
+ * This calls the subscriber receiver function synchronously.
+ **/
+ void
+ ocirc_event_publish(const ocirc_event_msg_t *msg)
+ {
+ SMARTLIST_FOREACH_BEGIN(ocirc_event_rcvrs, ocirc_event_rcvr_t, fn) {
+ tor_assert(fn);
+ (*fn)(msg);
+ } SMARTLIST_FOREACH_END(fn);
+ }
+
+ const subsys_fns_t sys_ocirc_event = {
+ .name = "ocirc_event",
+ .supported = true,
- .level = -39,
++ .level = -32,
+ .initialize = ocirc_event_init,
+ .shutdown = ocirc_event_fini,
+ };
diff --cc src/core/or/orconn_event.c
index 000000000,11f5ed966..d81f7b5a0
mode 000000,100644..100644
--- a/src/core/or/orconn_event.c
+++ b/src/core/or/orconn_event.c
@@@ -1,0 -1,81 +1,81 @@@
+ /* Copyright (c) 2007-2018, The Tor Project, Inc. */
+ /* See LICENSE for licensing information */
+
+ /**
+ * \file orconn_event.c
+ * \brief Publish state change messages for OR connections
+ *
+ * Implements a basic publish-subscribe framework for messages about
+ * the state of OR connections. The publisher calls the subscriber
+ * callback functions synchronously.
+ *
+ * Although the synchronous calls might not simplify the call graph,
+ * this approach improves data isolation because the publisher doesn't
+ * need knowledge about the internals of subscribing subsystems. It
+ * also avoids race conditions that might occur in asynchronous
+ * frameworks.
+ **/
+
+ #include "core/or/or.h"
+ #include "lib/subsys/subsys.h"
+
+ #define ORCONN_EVENT_PRIVATE
+ #include "core/or/orconn_event.h"
+ #include "core/or/orconn_event_sys.h"
+
+ /** List of subscribers */
+ static smartlist_t *orconn_event_rcvrs;
+
+ /** Initialize subscriber list */
+ static int
+ orconn_event_init(void)
+ {
+ orconn_event_rcvrs = smartlist_new();
+ return 0;
+ }
+
+ /** Free subscriber list */
+ static void
+ orconn_event_fini(void)
+ {
+ smartlist_free(orconn_event_rcvrs);
+ }
+
+ /**
+ * Subscribe to messages about OR connection events
+ *
+ * Register a callback function to receive messages about ORCONNs.
+ * The publisher calls this function synchronously.
+ **/
+ void
+ orconn_event_subscribe(orconn_event_rcvr_t fn)
+ {
+ tor_assert(fn);
+ /* Don't duplicate subscriptions. */
+ if (smartlist_contains(orconn_event_rcvrs, fn))
+ return;
+
+ smartlist_add(orconn_event_rcvrs, fn);
+ }
+
+ /**
+ * Publish a message about OR connection events
+ *
+ * This calls the subscriber receiver function synchronously.
+ **/
+ void
+ orconn_event_publish(const orconn_event_msg_t *msg)
+ {
+ SMARTLIST_FOREACH_BEGIN(orconn_event_rcvrs, orconn_event_rcvr_t, fn) {
+ tor_assert(fn);
+ (*fn)(msg);
+ } SMARTLIST_FOREACH_END(fn);
+ }
+
+ const subsys_fns_t sys_orconn_event = {
+ .name = "orconn_event",
+ .supported = true,
- .level = -40,
++ .level = -33,
+ .initialize = orconn_event_init,
+ .shutdown = orconn_event_fini,
+ };
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits