aboutsummaryrefslogtreecommitdiff
path: root/src/test/test_periodic_event.c
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@torproject.org>2018-04-27 11:14:12 -0400
committerDavid Goulet <dgoulet@torproject.org>2018-04-27 11:16:57 -0400
commitf7633c1fcaefe72bf97c001bab9062132c919996 (patch)
tree39670b8278d5b7f6c0d8102bc5c91b7ee37883f2 /src/test/test_periodic_event.c
parent3ab017b10c64e090a5a3f197315ddcdbc6de698c (diff)
downloadtor-f7633c1fcaefe72bf97c001bab9062132c919996.tar.gz
tor-f7633c1fcaefe72bf97c001bab9062132c919996.zip
hs: Rescan the main loop event list if the service map changes
Because ADD_ONION/DEL_ONION can modify the global service map (both for v2 and v3), we need to rescan the event list so we either enable or disable the HS service main loop event. Fixees #25939 Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/test/test_periodic_event.c')
-rw-r--r--src/test/test_periodic_event.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/test/test_periodic_event.c b/src/test/test_periodic_event.c
index bebbb5e584..9f62cd680d 100644
--- a/src/test/test_periodic_event.c
+++ b/src/test/test_periodic_event.c
@@ -69,7 +69,7 @@ test_pe_initialize(void *arg)
static void
test_pe_launch(void *arg)
{
- hs_service_t service;
+ hs_service_t service, *to_remove = NULL;
or_options_t *options;
(void) arg;
@@ -152,8 +152,11 @@ test_pe_launch(void *arg)
options->V3AuthoritativeDir = 1; options->BridgeAuthoritativeDir = 1;
register_dummy_hidden_service(&service);
periodic_events_on_new_options(options);
- /* Remove it now so the hs_free_all() doesn't try to free stack memory. */
- remove_service(get_hs_service_map(), &service);
+ /* Note down the reference because we need to remove this service from the
+ * global list before the hs_free_all() call so it doesn't try to free
+ * memory on the stack. Furthermore, we can't remove it now else it will
+ * trigger a rescan of the event disabling the HS service event. */
+ to_remove = &service;
for (int i = 0; periodic_events[i].name; ++i) {
periodic_event_item_t *item = &periodic_events[i];
@@ -161,6 +164,9 @@ test_pe_launch(void *arg)
}
done:
+ if (to_remove) {
+ remove_service(get_hs_service_map(), to_remove);
+ }
hs_free_all();
}