[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor/master] Set revision counter before uploading, not during building.
commit 4cfade2f4682fa2554f79b2edf51f9dde8f924dc
Author: George Kadianakis <desnacked@xxxxxxxxxx>
Date: Thu Jul 12 16:51:31 2018 +0300
Set revision counter before uploading, not during building.
We only build a descriptor once, and we just re-encode it (and change its intro
points if needed) before uploading.
Hence we should set the revision counter before uploading, not during building.
---
src/or/hs_service.c | 19 ++++++++-----------
1 file changed, 8 insertions(+), 11 deletions(-)
diff --git a/src/or/hs_service.c b/src/or/hs_service.c
index 3500e497b..5430ef4d8 100644
--- a/src/or/hs_service.c
+++ b/src/or/hs_service.c
@@ -1446,15 +1446,11 @@ build_service_desc_keys(const hs_service_t *service,
* the update function. On success, desc_out will point to the newly allocated
* descriptor object.
*
- * If <b>is_current</b> is true, this is the current service descriptor,
- * otherwise it's the next one.
- *
* This can error if we are unable to create keys or certificate. */
static void
build_service_descriptor(hs_service_t *service, time_t now,
uint64_t time_period_num,
- hs_service_descriptor_t **desc_out,
- bool is_current)
+ hs_service_descriptor_t **desc_out)
{
char *encoded_desc;
hs_service_descriptor_t *desc;
@@ -1480,9 +1476,6 @@ build_service_descriptor(hs_service_t *service, time_t now,
goto err;
}
- /* Set the revision counter for this descriptor */
- set_descriptor_revision_counter(desc, now, is_current);
-
/* Let's make sure that we've created a descriptor that can actually be
* encoded properly. This function also checks if the encoded output is
* decodable after. */
@@ -1547,9 +1540,9 @@ build_descriptors_for_new_service(hs_service_t *service, time_t now)
/* Build descriptors. */
build_service_descriptor(service, now, current_desc_tp,
- &service->desc_current, 1);
+ &service->desc_current);
build_service_descriptor(service, now, next_desc_tp,
- &service->desc_next, 0);
+ &service->desc_next);
log_info(LD_REND, "Hidden service %s has just started. Both descriptors "
"built. Now scheduled for upload.",
safe_str_client(service->onion_address));
@@ -1580,7 +1573,7 @@ build_all_descriptors(time_t now)
if (service->desc_next == NULL) {
build_service_descriptor(service, now, hs_get_next_time_period_num(0),
- &service->desc_next, 0);
+ &service->desc_next);
log_info(LD_REND, "Hidden service %s next descriptor successfully "
"built. Now scheduled for upload.",
safe_str_client(service->onion_address));
@@ -2631,6 +2624,10 @@ run_upload_descriptor_event(time_t now)
* accurate because all circuits have been established. */
build_desc_intro_points(service, desc, now);
+ /* Set the desc revision counter right before uploading */
+ set_descriptor_revision_counter(desc, approx_time(),
+ service->desc_current == desc);
+
upload_descriptor_to_all(service, desc);
} FOR_EACH_DESCRIPTOR_END;
} FOR_EACH_SERVICE_END;
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits