[tor-commits] [tor/master] Merge ocirc and orconn events into or subsystem.
nickm at torproject.org
nickm at torproject.org
Mon Feb 24 12:51:37 UTC 2020
commit 63b7dabdea6c25cba6604af5d9340799636985b3
Author: Nick Mathewson <nickm at torproject.org>
Date: Fri Feb 14 09:34:51 2020 -0500
Merge ocirc and orconn events into or subsystem.
Pubsub events are not supposed to have their own subsystems; they're
supposed to be part of a parent subsystem.
---
src/app/main/subsystem_list.c | 4 ----
src/core/or/include.am | 2 --
src/core/or/ocirc_event.c | 11 ++---------
src/core/or/ocirc_event_sys.h | 13 -------------
src/core/or/or_sys.c | 12 ++++++++++++
src/core/or/or_sys.h | 4 ++++
src/core/or/orconn_event.c | 11 ++---------
src/core/or/orconn_event_sys.h | 12 ------------
8 files changed, 20 insertions(+), 49 deletions(-)
diff --git a/src/app/main/subsystem_list.c b/src/app/main/subsystem_list.c
index 84c6e6ec0..06f39df2e 100644
--- a/src/app/main/subsystem_list.c
+++ b/src/app/main/subsystem_list.c
@@ -14,9 +14,7 @@
#include "lib/cc/torint.h"
#include "core/mainloop/mainloop_sys.h"
-#include "core/or/ocirc_event_sys.h"
#include "core/or/or_sys.h"
-#include "core/or/orconn_event_sys.h"
#include "feature/control/btrack_sys.h"
#include "lib/compress/compress_sys.h"
#include "lib/crypt_ops/crypto_sys.h"
@@ -61,8 +59,6 @@ const subsys_fns_t *tor_subsystems[] = {
&sys_mainloop,
&sys_or,
- &sys_orconn_event,
- &sys_ocirc_event,
&sys_relay,
diff --git a/src/core/or/include.am b/src/core/or/include.am
index 4dd251d2e..3626e76be 100644
--- a/src/core/or/include.am
+++ b/src/core/or/include.am
@@ -74,13 +74,11 @@ noinst_HEADERS += \
src/core/or/or_periodic.h \
src/core/or/or_sys.h \
src/core/or/orconn_event.h \
- src/core/or/orconn_event_sys.h \
src/core/or/or_circuit_st.h \
src/core/or/or_connection_st.h \
src/core/or/or_handshake_certs_st.h \
src/core/or/or_handshake_state_st.h \
src/core/or/ocirc_event.h \
- src/core/or/ocirc_event_sys.h \
src/core/or/origin_circuit_st.h \
src/core/or/policies.h \
src/core/or/port_cfg_st.h \
diff --git a/src/core/or/ocirc_event.c b/src/core/or/ocirc_event.c
index 6aa7f684e..fa1645917 100644
--- a/src/core/or/ocirc_event.c
+++ b/src/core/or/ocirc_event.c
@@ -22,7 +22,7 @@
#include "core/or/cpath_build_state_st.h"
#include "core/or/ocirc_event.h"
-#include "core/or/ocirc_event_sys.h"
+#include "core/or/or_sys.h"
#include "core/or/origin_circuit_st.h"
#include "lib/subsys/subsys.h"
@@ -84,7 +84,7 @@ static dispatch_typefns_t ocirc_cevent_fns = {
.fmt_fn = ocirc_cevent_fmt,
};
-static int
+int
ocirc_add_pubsub(struct pubsub_connector_t *connector)
{
if (DISPATCH_REGISTER_TYPE(connector, ocirc_state, ô_state_fns))
@@ -119,10 +119,3 @@ ocirc_cevent_publish(ocirc_cevent_msg_t *msg)
{
PUBLISH(ocirc_cevent, msg);
}
-
-const subsys_fns_t sys_ocirc_event = {
- .name = "ocirc_event",
- .supported = true,
- .level = 22,
- .add_pubsub = ocirc_add_pubsub,
-};
diff --git a/src/core/or/ocirc_event_sys.h b/src/core/or/ocirc_event_sys.h
deleted file mode 100644
index abb89b04a..000000000
--- a/src/core/or/ocirc_event_sys.h
+++ /dev/null
@@ -1,13 +0,0 @@
-/* Copyright (c) 2007-2020, The Tor Project, Inc. */
-
-/**
- * \file ocirc_event_sys.h
- * \brief Declare subsystem object for the origin circuit event module.
- **/
-
-#ifndef TOR_OCIRC_EVENT_SYS_H
-#define TOR_OCIRC_EVENT_SYS_H
-
-extern const struct subsys_fns_t sys_ocirc_event;
-
-#endif /* !defined(TOR_OCIRC_EVENT_SYS_H) */
diff --git a/src/core/or/or_sys.c b/src/core/or/or_sys.c
index 394b7945e..126f5448c 100644
--- a/src/core/or/or_sys.c
+++ b/src/core/or/or_sys.c
@@ -34,10 +34,22 @@ subsys_or_shutdown(void)
policies_free_all();
}
+static int
+subsys_or_add_pubsub(struct pubsub_connector_t *connector)
+{
+ int rv = 0;
+ if (orconn_add_pubsub(connector) < 0)
+ rv = -1;
+ if (ocirc_add_pubsub(connector) < 0)
+ rv = -1;
+ return rv;
+}
+
const struct subsys_fns_t sys_or = {
.name = "or",
.supported = true,
.level = 20,
.initialize = subsys_or_initialize,
.shutdown = subsys_or_shutdown,
+ .add_pubsub = subsys_or_add_pubsub,
};
diff --git a/src/core/or/or_sys.h b/src/core/or/or_sys.h
index 3ae09f7b5..7ee56c868 100644
--- a/src/core/or/or_sys.h
+++ b/src/core/or/or_sys.h
@@ -14,4 +14,8 @@
extern const struct subsys_fns_t sys_or;
+struct pubsub_connector_t;
+int ocirc_add_pubsub(struct pubsub_connector_t *connector);
+int orconn_add_pubsub(struct pubsub_connector_t *connector);
+
#endif /* !defined(TOR_CORE_OR_OR_SYS_H) */
diff --git a/src/core/or/orconn_event.c b/src/core/or/orconn_event.c
index 7ed6b5fdf..c30e2dd22 100644
--- a/src/core/or/orconn_event.c
+++ b/src/core/or/orconn_event.c
@@ -22,7 +22,7 @@
#define ORCONN_EVENT_PRIVATE
#include "core/or/orconn_event.h"
-#include "core/or/orconn_event_sys.h"
+#include "core/or/or_sys.h"
DECLARE_PUBLISH(orconn_state);
DECLARE_PUBLISH(orconn_status);
@@ -65,7 +65,7 @@ static dispatch_typefns_t orconn_status_fns = {
.fmt_fn = orconn_status_fmt,
};
-static int
+int
orconn_add_pubsub(struct pubsub_connector_t *connector)
{
if (DISPATCH_REGISTER_TYPE(connector, orconn_state, &orconn_state_fns))
@@ -90,10 +90,3 @@ orconn_status_publish(orconn_status_msg_t *msg)
{
PUBLISH(orconn_status, msg);
}
-
-const subsys_fns_t sys_orconn_event = {
- .name = "orconn_event",
- .supported = true,
- .level = 22,
- .add_pubsub = orconn_add_pubsub,
-};
diff --git a/src/core/or/orconn_event_sys.h b/src/core/or/orconn_event_sys.h
deleted file mode 100644
index 02f0b8116..000000000
--- a/src/core/or/orconn_event_sys.h
+++ /dev/null
@@ -1,12 +0,0 @@
-/* Copyright (c) 2007-2020, The Tor Project, Inc. */
-
-/**
- * \file orconn_event_sys.h
- * \brief Declare subsystem object for the OR connection event module.
- **/
-#ifndef TOR_ORCONN_EVENT_SYS_H
-#define TOR_ORCONN_EVENT_SYS_H
-
-extern const struct subsys_fns_t sys_orconn_event;
-
-#endif /* !defined(TOR_ORCONN_EVENT_SYS_H) */
More information about the tor-commits
mailing list