diff options
author | David Goulet <dgoulet@torproject.org> | 2021-03-10 09:12:29 -0500 |
---|---|---|
committer | David Goulet <dgoulet@torproject.org> | 2021-03-10 09:12:29 -0500 |
commit | f93ccb8d247ad2a601b697ca2ed0004f428fbd15 (patch) | |
tree | 200180bdee9ae8da6011357f9c95585b61cd62ba /src/feature/hs | |
parent | 49ce31b2b6c0cfbcccb605ee58b612f73e2a228a (diff) | |
download | tor-f93ccb8d247ad2a601b697ca2ed0004f428fbd15.tar.gz tor-f93ccb8d247ad2a601b697ca2ed0004f428fbd15.zip |
hs: Remove hamrless BUG() that can happen
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>
Diffstat (limited to 'src/feature/hs')
-rw-r--r-- | src/feature/hs/hs_metrics.c | 8 | ||||
-rw-r--r-- | src/feature/hs/hs_service.c | 4 |
2 files changed, 8 insertions, 4 deletions
diff --git a/src/feature/hs/hs_metrics.c b/src/feature/hs/hs_metrics.c index 67cae8ec0e..e6d3084f26 100644 --- a/src/feature/hs/hs_metrics.c +++ b/src/feature/hs/hs_metrics.c @@ -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; } diff --git a/src/feature/hs/hs_service.c b/src/feature/hs/hs_service.c index 07e3550986..908ac02044 100644 --- a/src/feature/hs/hs_service.c +++ b/src/feature/hs/hs_service.c @@ -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; |