Browse Source

Use the subsystem list to initialize and shutdown process module.

This patch makes the process module use the subsystem list for
initializing and shutting down.

See: https://bugs.torproject.org/28847
Alexander Færøy 5 years ago
parent
commit
cf4b3dbd44

+ 3 - 0
changes/ticket28847

@@ -0,0 +1,3 @@
+  o Minor features (process):
+    - Use the subsystem module to initialize and shut down the process module.
+      Closes ticket 28847.

+ 2 - 0
src/app/main/subsystem_list.c

@@ -18,6 +18,7 @@
 #include "lib/time/time_sys.h"
 #include "lib/tls/tortls_sys.h"
 #include "lib/wallclock/wallclock_sys.h"
+#include "lib/process/process_sys.h"
 
 #include <stddef.h>
 
@@ -32,6 +33,7 @@ const subsys_fns_t *tor_subsystems[] = {
   &sys_logging, /* -90 */
   &sys_time, /* -90 */
   &sys_network, /* -90 */
+  &sys_process, /* -80 */
   &sys_compress, /* -70 */
   &sys_crypto, /* -60 */
   &sys_tortls, /* -50 */

+ 2 - 0
src/lib/process/include.am

@@ -10,6 +10,7 @@ src_lib_libtor_process_a_SOURCES =		\
 	src/lib/process/env.c			\
 	src/lib/process/pidfile.c		\
 	src/lib/process/process.c		\
+	src/lib/process/process_sys.c		\
 	src/lib/process/process_unix.c		\
 	src/lib/process/process_win32.c		\
 	src/lib/process/restrict.c		\
@@ -27,6 +28,7 @@ noinst_HEADERS +=				\
 	src/lib/process/env.h			\
 	src/lib/process/pidfile.h		\
 	src/lib/process/process.h		\
+	src/lib/process/process_sys.h		\
 	src/lib/process/process_unix.h		\
 	src/lib/process/process_win32.h		\
 	src/lib/process/restrict.h		\

+ 33 - 0
src/lib/process/process_sys.c

@@ -0,0 +1,33 @@
+/* Copyright (c) 2018, The Tor Project, Inc. */
+/* See LICENSE for licensing information */
+
+/**
+ * \file process_sys.c
+ * \brief Subsystem object for process setup.
+ **/
+
+#include "orconfig.h"
+#include "lib/subsys/subsys.h"
+#include "lib/process/process_sys.h"
+#include "lib/process/process.h"
+
+static int
+subsys_process_initialize(void)
+{
+  process_init();
+  return 0;
+}
+
+static void
+subsys_process_shutdown(void)
+{
+  process_free_all();
+}
+
+const subsys_fns_t sys_process = {
+  .name = "process",
+  .level = -80,
+  .supported = true,
+  .initialize = subsys_process_initialize,
+  .shutdown = subsys_process_shutdown
+};

+ 14 - 0
src/lib/process/process_sys.h

@@ -0,0 +1,14 @@
+/* Copyright (c) 2018, The Tor Project, Inc. */
+/* See LICENSE for licensing information */
+
+/**
+ * \file process_sys.h
+ * \brief Declare subsystem object for the process module.
+ **/
+
+#ifndef TOR_PROCESS_SYS_H
+#define TOR_PROCESS_SYS_H
+
+extern const struct subsys_fns_t sys_process;
+
+#endif /* !defined(TOR_PROCESS_SYS_H) */