]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
hs: Remove hamrless BUG() that can happen
authorDavid Goulet <dgoulet@torproject.org>
Wed, 10 Mar 2021 14:12:29 +0000 (09:12 -0500)
committerDavid Goulet <dgoulet@torproject.org>
Wed, 10 Mar 2021 14:12:29 +0000 (09:12 -0500)
When reloading a service, we can re-register a service and thus end up again
in the metrics store initialization code path which is fine. No need to BUG()
anymore.

Fixes #40334

Signed-off-by: David Goulet <dgoulet@torproject.org>
changes/ticket40334 [new file with mode: 0644]
src/feature/hs/hs_metrics.c
src/feature/hs/hs_service.c

diff --git a/changes/ticket40334 b/changes/ticket40334
new file mode 100644 (file)
index 0000000..c1c3438
--- /dev/null
@@ -0,0 +1,3 @@
+  o Minor bugfixes (onion service):
+    - Remove a harmless BUG() warning when reloading tor configured with onion
+      services. Fixes bug 40334; bugfix on 0.4.5.1-alpha.
index 67cae8ec0ebd323328063c5d54b30353b27ebd0f..e6d3084f2690ab471f4f0cf85fe9e76171f6ceb6 100644 (file)
@@ -149,9 +149,11 @@ hs_metrics_service_init(hs_service_t *service)
 {
   tor_assert(service);
 
-  /* Calling this function twice on a service object is wrong. The caller must
-   * free the metrics before if so. */
-  if (BUG(service->metrics.store)) {
+  /* This function is called when we register a service and so it could either
+   * be a new service or a service that was just reloaded through a HUP signal
+   * for instance. Thus, it is possible that the service has already an
+   * initialized store. If so, just return. */
+  if (service->metrics.store) {
     return;
   }
 
index 07e35509869de525a2b9f2d46d985c80f13881b4..908ac020449ce19ce1d72da53e3c2aa8a56741fb 100644 (file)
@@ -197,7 +197,9 @@ register_service(hs_service_ht *map, hs_service_t *service)
   if (map == hs_service_map) {
     hs_service_map_has_changed();
   }
-  /* Setup metrics. */
+  /* Setup metrics. This is done here because in order to initialize metrics,
+   * we require tor to have fully initialized a service so the ports of the
+   * service can be looked at for instance. */
   hs_metrics_service_init(service);
 
   return 0;