summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.am11
-rw-r--r--changes/bug307994
-rw-r--r--changes/ticket193814
-rw-r--r--changes/ticket295333
-rw-r--r--changes/ticket308063
-rw-r--r--configure.ac8
-rw-r--r--doc/include.am23
-rwxr-xr-xscripts/git/pre-push.git-hook1
-rw-r--r--scripts/maint/practracker/exceptions.txt2
-rw-r--r--src/app/main/main.c4
-rw-r--r--src/app/main/ntmain.c1
-rw-r--r--src/app/main/shutdown.c2
-rw-r--r--src/app/main/subsystem_list.c3
-rw-r--r--src/lib/evloop/.may_include1
-rw-r--r--src/lib/evloop/evloop_sys.c49
-rw-r--r--src/lib/evloop/evloop_sys.h17
-rw-r--r--src/lib/evloop/include.am2
-rw-r--r--src/test/test_channelpadding.c7
-rw-r--r--src/test/test_compat_libevent.c2
19 files changed, 125 insertions, 22 deletions
diff --git a/Makefile.am b/Makefile.am
index 7a0d40d6a5..df30e0b59a 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -224,10 +224,19 @@ test: all
shellcheck:
# Only use shellcheck if it is present
if command -v shellcheck; then \
- find $(top_srcdir)/scripts/ -name "*.sh" -exec shellcheck {} +; \
+ find "$(top_srcdir)" -name "*.sh" -not -path "$(top_srcdir)/src/ext/*" -exec shellcheck {} +; \
if [ -d "$(top_srcdir)/scripts/test" ]; then \
shellcheck $(top_srcdir)/scripts/test/cov-diff $(top_srcdir)/scripts/test/coverage; \
fi; \
+ if [ -e "$(top_srcdir)/contrib/dirauth-tools/nagios-check-tor-authority-cert" ]; then \
+ shellcheck "$(top_srcdir)/contrib/dirauth-tools/nagios-check-tor-authority-cert"; \
+ fi; \
+ if [ -e "$(top_srcdir)/contrib/client-tools/torify" ]; then \
+ shellcheck "$(top_srcdir)/contrib/client-tools/torify"; \
+ fi; \
+ if [ -d "$(top_srcdir)/scripts/git" ]; then \
+ shellcheck $(top_srcdir)/scripts/git/*.git-hook; \
+ fi; \
fi
check-local: check-spaces check-changes check-includes check-best-practices shellcheck
diff --git a/changes/bug30799 b/changes/bug30799
new file mode 100644
index 0000000000..b10420a953
--- /dev/null
+++ b/changes/bug30799
@@ -0,0 +1,4 @@
+ o Minor bugfixes (memory management):
+ - Stop leaking a small amount of memory in nt_service_install(), in
+ unreachable code. Fixes bug 30799; bugfix on 0.2.0.7-alpha.
+ Patch by Xiaoyin Liu.
diff --git a/changes/ticket19381 b/changes/ticket19381
new file mode 100644
index 0000000000..ee51e2a3e2
--- /dev/null
+++ b/changes/ticket19381
@@ -0,0 +1,4 @@
+ o Minor features (build system):
+ - Add --disable-manpage and --disable-html-manual options to configure
+ script. This will enable shortening build times by not building
+ documentation. Resolves issue 19381.
diff --git a/changes/ticket29533 b/changes/ticket29533
new file mode 100644
index 0000000000..27ef681218
--- /dev/null
+++ b/changes/ticket29533
@@ -0,0 +1,3 @@
+ o Testing:
+ - Run shellcheck for all non-third-party shell scripts that are shipped
+ with Tor. Closes ticket 29533.
diff --git a/changes/ticket30806 b/changes/ticket30806
new file mode 100644
index 0000000000..4f09ea2af3
--- /dev/null
+++ b/changes/ticket30806
@@ -0,0 +1,3 @@
+ o Code simplification and refactoring:
+ - Use the subsystems mechanism to manage the main event loop code.
+ Closes ticket 30806.
diff --git a/configure.ac b/configure.ac
index 75ca03d7d8..9ec123f51e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -105,6 +105,12 @@ if test "$enable_memory_sentinels" = "no"; then
[Defined if we're turning off memory safety code to look for bugs])
fi
+AC_ARG_ENABLE(manpage,
+ AS_HELP_STRING(--disable-manpage, [Disable manpage generation.]))
+
+AC_ARG_ENABLE(html-manual,
+ AS_HELP_STRING(--disable-html-manual, [Disable HTML documentation.]))
+
AC_ARG_ENABLE(asciidoc,
AS_HELP_STRING(--disable-asciidoc, [don't use asciidoc (disables building of manpages)]),
[case "${enableval}" in
@@ -299,6 +305,8 @@ AC_PATH_PROG([ASCIIDOC], [asciidoc], none)
AC_PATH_PROGS([A2X], [a2x a2x.py], none)
AM_CONDITIONAL(USE_ASCIIDOC, test "x$asciidoc" = "xtrue")
+AM_CONDITIONAL(BUILD_MANPAGE, [test "x$enable_manpage" != "xno"])
+AM_CONDITIONAL(BUILD_HTML_DOCS, [test "x$enable_html_manual" != "xno"])
AM_PROG_CC_C_O
AC_PROG_CC_C99
diff --git a/doc/include.am b/doc/include.am
index 0a123aae11..a9d3fa1c98 100644
--- a/doc/include.am
+++ b/doc/include.am
@@ -15,17 +15,32 @@
all_mans = doc/tor doc/tor-gencert doc/tor-resolve doc/torify doc/tor-print-ed-signing-cert
if USE_ASCIIDOC
-nodist_man1_MANS = $(all_mans:=.1)
-doc_DATA = $(all_mans:=.html)
+txt_in = $(all_mans:=.1.txt)
+
+if BUILD_HTML_DOCS
html_in = $(all_mans:=.html.in)
+doc_DATA = $(all_mans:=.html)
+else
+html_in =
+doc_DATA =
+endif
+
+if BUILD_MANPAGE
+nodist_man1_MANS = $(all_mans:=.1)
man_in = $(all_mans:=.1.in)
-txt_in = $(all_mans:=.1.txt)
else
+nodist_man1_MANS =
+man_in =
+endif
+
+else
+
html_in =
+doc_DATA =
man_in =
txt_in =
nodist_man1_MANS =
-doc_DATA =
+
endif
EXTRA_DIST+= doc/asciidoc-helper.sh \
diff --git a/scripts/git/pre-push.git-hook b/scripts/git/pre-push.git-hook
index 51b0c896c8..71abc9aa2b 100755
--- a/scripts/git/pre-push.git-hook
+++ b/scripts/git/pre-push.git-hook
@@ -35,7 +35,6 @@ if [ -e scripts/maint/practracker/practracker.py ]; then
fi
remote="$1"
-remote_loc="$2"
remote_name=$(git remote --verbose | grep "$2" | awk '{print $1}' | head -n 1)
diff --git a/scripts/maint/practracker/exceptions.txt b/scripts/maint/practracker/exceptions.txt
index 282071f0d9..815d0ed097 100644
--- a/scripts/maint/practracker/exceptions.txt
+++ b/scripts/maint/practracker/exceptions.txt
@@ -52,7 +52,7 @@ problem function-size /src/app/main/main.c:dumpstats() 102
problem function-size /src/app/main/main.c:tor_init() 137
problem function-size /src/app/main/main.c:sandbox_init_filter() 291
problem function-size /src/app/main/main.c:run_tor_main_loop() 105
-problem function-size /src/app/main/ntmain.c:nt_service_install() 125
+problem function-size /src/app/main/ntmain.c:nt_service_install() 126
problem file-size /src/core/mainloop/connection.c 5569
problem include-count /src/core/mainloop/connection.c 62
problem function-size /src/core/mainloop/connection.c:connection_free_minimal() 185
diff --git a/src/app/main/main.c b/src/app/main/main.c
index 04a0cec19d..31cee37637 100644
--- a/src/app/main/main.c
+++ b/src/app/main/main.c
@@ -653,10 +653,6 @@ tor_init(int argc, char *argv[])
return -1;
}
- if (tor_init_libevent_rng() < 0) {
- log_warn(LD_NET, "Problem initializing libevent RNG.");
- }
-
/* Scan/clean unparseable descriptors; after reading config */
routerparse_init();
diff --git a/src/app/main/ntmain.c b/src/app/main/ntmain.c
index f00b712702..a2de5bb87e 100644
--- a/src/app/main/ntmain.c
+++ b/src/app/main/ntmain.c
@@ -608,6 +608,7 @@ nt_service_install(int argc, char **argv)
&sidUse) == 0) {
/* XXXX For some reason, the above test segfaults. Fix that. */
printf("User \"%s\" doesn't seem to exist.\n", user_acct);
+ tor_free(command);
return -1;
} else {
printf("Will try to install service as user \"%s\".\n", user_acct);
diff --git a/src/app/main/shutdown.c b/src/app/main/shutdown.c
index cc0091a9ab..93d6351d1b 100644
--- a/src/app/main/shutdown.c
+++ b/src/app/main/shutdown.c
@@ -160,8 +160,6 @@ tor_free_all(int postfork)
subsystems_shutdown();
- tor_libevent_free_all();
-
/* Stuff in util.c and address.c*/
if (!postfork) {
esc_router_info(NULL);
diff --git a/src/app/main/subsystem_list.c b/src/app/main/subsystem_list.c
index f595796232..95d96f78d2 100644
--- a/src/app/main/subsystem_list.c
+++ b/src/app/main/subsystem_list.c
@@ -25,6 +25,7 @@
#include "lib/time/time_sys.h"
#include "lib/tls/tortls_sys.h"
#include "lib/wallclock/wallclock_sys.h"
+#include "lib/evloop/evloop_sys.h"
#include "feature/dirauth/dirauth_sys.h"
@@ -50,6 +51,8 @@ const subsys_fns_t *tor_subsystems[] = {
&sys_ocirc_event, /* -32 */
&sys_btrack, /* -30 */
+ &sys_evloop, /* -20 */
+
&sys_mainloop, /* 5 */
&sys_or, /* 20 */
diff --git a/src/lib/evloop/.may_include b/src/lib/evloop/.may_include
index 273de7bb94..54aa75fbff 100644
--- a/src/lib/evloop/.may_include
+++ b/src/lib/evloop/.may_include
@@ -8,6 +8,7 @@ lib/log/*.h
lib/malloc/*.h
lib/net/*.h
lib/string/*.h
+lib/subsys/*.h
lib/testsupport/*.h
lib/thread/*.h
lib/time/*.h
diff --git a/src/lib/evloop/evloop_sys.c b/src/lib/evloop/evloop_sys.c
new file mode 100644
index 0000000000..56641a3175
--- /dev/null
+++ b/src/lib/evloop/evloop_sys.c
@@ -0,0 +1,49 @@
+/* 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 evloop_sys.c
+ * @brief Subsystem definition for the event loop module
+ **/
+
+#include "orconfig.h"
+#include "lib/subsys/subsys.h"
+#include "lib/evloop/compat_libevent.h"
+#include "lib/evloop/evloop_sys.h"
+#include "lib/log/log.h"
+
+static int
+subsys_evloop_initialize(void)
+{
+ if (tor_init_libevent_rng() < 0) {
+ log_warn(LD_NET, "Problem initializing libevent RNG.");
+ return -1;
+ }
+ return 0;
+}
+
+static void
+subsys_evloop_postfork(void)
+{
+#ifdef TOR_UNIT_TESTS
+ tor_libevent_postfork();
+#endif
+}
+
+static void
+subsys_evloop_shutdown(void)
+{
+ tor_libevent_free_all();
+}
+
+const struct subsys_fns_t sys_evloop = {
+ .name = "evloop",
+ .supported = true,
+ .level = -20,
+ .initialize = subsys_evloop_initialize,
+ .shutdown = subsys_evloop_shutdown,
+ .postfork = subsys_evloop_postfork,
+};
diff --git a/src/lib/evloop/evloop_sys.h b/src/lib/evloop/evloop_sys.h
new file mode 100644
index 0000000000..e6155c25b0
--- /dev/null
+++ b/src/lib/evloop/evloop_sys.h
@@ -0,0 +1,17 @@
+/* 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 evloop_sys.h
+ * @brief Declare subsystem object for the event loop module.
+ **/
+
+#ifndef TOR_LIB_EVLOOP_EVLOOP_SYS_H
+#define TOR_LIB_EVLOOP_EVLOOP_SYS_H
+
+extern const struct subsys_fns_t sys_evloop;
+
+#endif /* !defined(TOR_LIB_EVLOOP_EVLOOP_SYS_H) */
diff --git a/src/lib/evloop/include.am b/src/lib/evloop/include.am
index 6595b3a34b..41cd2f45c5 100644
--- a/src/lib/evloop/include.am
+++ b/src/lib/evloop/include.am
@@ -8,6 +8,7 @@ endif
# ADD_C_FILE: INSERT SOURCES HERE.
src_lib_libtor_evloop_a_SOURCES = \
src/lib/evloop/compat_libevent.c \
+ src/lib/evloop/evloop_sys.c \
src/lib/evloop/procmon.c \
src/lib/evloop/timers.c \
src/lib/evloop/token_bucket.c \
@@ -21,6 +22,7 @@ src_lib_libtor_evloop_testing_a_CFLAGS = $(AM_CFLAGS) $(TEST_CFLAGS)
# ADD_C_FILE: INSERT HEADERS HERE.
noinst_HEADERS += \
src/lib/evloop/compat_libevent.h \
+ src/lib/evloop/evloop_sys.h \
src/lib/evloop/procmon.h \
src/lib/evloop/timers.h \
src/lib/evloop/token_bucket.h \
diff --git a/src/test/test_channelpadding.c b/src/test/test_channelpadding.c
index 5d012e462b..885246628e 100644
--- a/src/test/test_channelpadding.c
+++ b/src/test/test_channelpadding.c
@@ -289,8 +289,6 @@ test_channelpadding_timers(void *arg)
channel_t *chans[CHANNELS_TO_TEST];
(void)arg;
- tor_libevent_postfork();
-
if (!connection_array)
connection_array = smartlist_new();
@@ -393,7 +391,6 @@ test_channelpadding_killonehop(void *arg)
channelpadding_decision_t decision;
int64_t new_time;
(void)arg;
- tor_libevent_postfork();
routerstatus_t *relay = tor_malloc_zero(sizeof(routerstatus_t));
monotime_init();
@@ -502,8 +499,6 @@ test_channelpadding_consensus(void *arg)
int64_t new_time;
(void)arg;
- tor_libevent_postfork();
-
/*
* Params tested:
* nf_pad_before_usage
@@ -898,8 +893,6 @@ test_channelpadding_decide_to_pad_channel(void *arg)
connection_array = smartlist_new();
(void)arg;
- tor_libevent_postfork();
-
monotime_init();
monotime_enable_test_mocking();
monotime_set_mock_time_nsec(1);
diff --git a/src/test/test_compat_libevent.c b/src/test/test_compat_libevent.c
index 5d625483da..ecd97e3474 100644
--- a/src/test/test_compat_libevent.c
+++ b/src/test/test_compat_libevent.c
@@ -151,8 +151,6 @@ test_compat_libevent_postloop_events(void *arg)
mainloop_event_t *a = NULL, *b = NULL;
periodic_timer_t *timed = NULL;
- tor_libevent_postfork();
-
/* If postloop events don't work, then these events will activate one
* another ad infinitum and, and the periodic event will never occur. */
b = mainloop_event_postloop_new(activate_event_cb, &a);