[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor/master] Add "stub" files for disabled modules.
commit 5e2318165dba782f6daa6620b17e0fa1e72b4b11
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date: Sun Dec 15 18:10:11 2019 -0500
Add "stub" files for disabled modules.
These modules are only built when the selected modules are disabled.
The provide stub implementations of the subsystem blocks. Later,
other stub implementations could move here.
Having real subsystem blocks here will let us handle disabled
configuration options better.
---
src/app/main/subsystem_list.c | 4 ----
src/core/include.am | 13 ++++++++++++-
src/feature/dirauth/dirauth_stub.c | 19 +++++++++++++++++++
src/feature/dirauth/dirauth_sys.h | 4 ----
src/feature/relay/relay_stub.c | 20 ++++++++++++++++++++
src/feature/relay/relay_sys.h | 4 ----
6 files changed, 51 insertions(+), 13 deletions(-)
diff --git a/src/app/main/subsystem_list.c b/src/app/main/subsystem_list.c
index a343207c1..8b217715a 100644
--- a/src/app/main/subsystem_list.c
+++ b/src/app/main/subsystem_list.c
@@ -66,13 +66,9 @@ const subsys_fns_t *tor_subsystems[] = {
&sys_mainloop,
&sys_or,
-#ifdef HAVE_MODULE_RELAY
&sys_relay,
-#endif
-#ifdef HAVE_MODULE_DIRAUTH
&sys_dirauth,
-#endif
};
const unsigned n_tor_subsystems = ARRAY_LENGTH(tor_subsystems);
diff --git a/src/core/include.am b/src/core/include.am
index 83230fb3c..ab4adeaf6 100644
--- a/src/core/include.am
+++ b/src/core/include.am
@@ -157,6 +157,11 @@ LIBTOR_APP_A_SOURCES = \
src/feature/stats/rephist.c \
src/feature/stats/predict_ports.c
+#
+# Sources that we only add for the real libtor_a, and not for testing.
+#
+LIBTOR_APP_A_STUB_SOURCES =
+
if BUILD_NT_SERVICES
LIBTOR_APP_A_SOURCES += src/app/main/ntmain.c
endif
@@ -199,13 +204,19 @@ MODULE_DIRAUTH_SOURCES = \
if BUILD_MODULE_RELAY
LIBTOR_APP_A_SOURCES += $(MODULE_RELAY_SOURCES)
+else
+LIBTOR_APP_A_STUB_SOURCES += src/feature/relay/relay_stub.c
endif
if BUILD_MODULE_DIRAUTH
LIBTOR_APP_A_SOURCES += $(MODULE_DIRAUTH_SOURCES)
+else
+LIBTOR_APP_A_STUB_SOURCES += src/feature/dirauth/dirauth_stub.c
endif
-src_core_libtor_app_a_SOURCES = $(LIBTOR_APP_A_SOURCES)
+src_core_libtor_app_a_SOURCES = \
+ $(LIBTOR_APP_A_SOURCES) \
+ $(LIBTOR_APP_A_STUB_SOURCES)
if UNITTESTS_ENABLED
# Add the sources of the modules that are needed for tests to work here.
diff --git a/src/feature/dirauth/dirauth_stub.c b/src/feature/dirauth/dirauth_stub.c
new file mode 100644
index 000000000..fac68edd0
--- /dev/null
+++ b/src/feature/dirauth/dirauth_stub.c
@@ -0,0 +1,19 @@
+/* Copyright (c) 2001 Matej Pfajfar.
+ * Copyright (c) 2001-2004, Roger Dingledine.
+ * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
+ * Copyright (c) 2007-2019, The Tor Project, Inc. */
+/* See LICENSE for licensing information */
+
+/**
+ * @file dirauth_stub.c
+ * @brief Stub declarations for use when dirauth module is disabled.
+ **/
+
+#include "orconfig.h"
+#include "feature/dirauth/dirauth_sys.h"
+
+const struct subsys_fns_t sys_dirauth = {
+ .name = "dirauth",
+ .supported = false,
+ .level = 70,
+};
diff --git a/src/feature/dirauth/dirauth_sys.h b/src/feature/dirauth/dirauth_sys.h
index 86c8d8ba3..2d5a0cb3e 100644
--- a/src/feature/dirauth/dirauth_sys.h
+++ b/src/feature/dirauth/dirauth_sys.h
@@ -12,10 +12,6 @@
#ifndef DIRAUTH_SYS_H
#define DIRAUTH_SYS_H
-#ifdef HAVE_MODULE_DIRAUTH
-
extern const struct subsys_fns_t sys_dirauth;
-#endif
-
#endif /* !defined(DIRAUTH_SYS_H) */
diff --git a/src/feature/relay/relay_stub.c b/src/feature/relay/relay_stub.c
new file mode 100644
index 000000000..a23b99186
--- /dev/null
+++ b/src/feature/relay/relay_stub.c
@@ -0,0 +1,20 @@
+/* Copyright (c) 2001 Matej Pfajfar.
+ * Copyright (c) 2001-2004, Roger Dingledine.
+ * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
+ * Copyright (c) 2007-2019, The Tor Project, Inc. */
+/* See LICENSE for licensing information */
+
+/**
+ * @file relay_stub.c
+ * @brief Stub declarations for use when relay module is disabled.
+ **/
+
+#include "orconfig.h"
+#include "feature/relay/relay_sys.h"
+#include "lib/subsys/subsys.h"
+
+const struct subsys_fns_t sys_relay = {
+ .name = "relay",
+ .supported = false,
+ .level = 50,
+};
diff --git a/src/feature/relay/relay_sys.h b/src/feature/relay/relay_sys.h
index aa387369b..32e21d90d 100644
--- a/src/feature/relay/relay_sys.h
+++ b/src/feature/relay/relay_sys.h
@@ -12,10 +12,6 @@
#ifndef TOR_FEATURE_RELAY_RELAY_SYS_H
#define TOR_FEATURE_RELAY_RELAY_SYS_H
-#ifdef HAVE_MODULE_RELAY
-
extern const struct subsys_fns_t sys_relay;
-#endif
-
#endif /* !defined(TOR_FEATURE_RELAY_RELAY_SYS_H) */
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits