aboutsummaryrefslogtreecommitdiff
path: root/src/or/hs_service.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2017-09-04 12:30:51 -0400
committerNick Mathewson <nickm@torproject.org>2017-09-04 12:30:51 -0400
commit834e1f8085af43c8f7bd07c346cf6f760a519f13 (patch)
tree1617702194c74c2750dea927bf6054b4548bfa60 /src/or/hs_service.c
parent109cfebca540c80d176cde54e672e72ab8908139 (diff)
parentb9f849bdee20f36264fe061498536e0d3a8616a6 (diff)
downloadtor-834e1f8085af43c8f7bd07c346cf6f760a519f13.tar.gz
tor-834e1f8085af43c8f7bd07c346cf6f760a519f13.zip
Merge remote-tracking branch 'asn/bug23346'
Diffstat (limited to 'src/or/hs_service.c')
-rw-r--r--src/or/hs_service.c36
1 files changed, 15 insertions, 21 deletions
diff --git a/src/or/hs_service.c b/src/or/hs_service.c
index 82adc7d455..796efa0c9b 100644
--- a/src/or/hs_service.c
+++ b/src/or/hs_service.c
@@ -1562,7 +1562,6 @@ service_desc_note_upload(hs_service_descriptor_t *desc, const node_t *hsdir)
if (!smartlist_contains_string(desc->previous_hsdirs, b64_digest)) {
smartlist_add_strdup(desc->previous_hsdirs, b64_digest);
- smartlist_sort_strings(desc->previous_hsdirs);
}
}
@@ -2333,6 +2332,10 @@ upload_descriptor_to_all(const hs_service_t *service,
hs_get_responsible_hsdirs(&desc->blinded_kp.pubkey, desc->time_period_num,
for_next_period, 0, responsible_dirs);
+ /** Clear list of previous hsdirs since we are about to upload to a new
+ * list. Let's keep it up to date. */
+ service_desc_clear_previous_hsdirs(desc);
+
/* For each responsible HSDir we have, initiate an upload command. */
SMARTLIST_FOREACH_BEGIN(responsible_dirs, const routerstatus_t *,
hsdir_rs) {
@@ -2370,9 +2373,8 @@ STATIC int
service_desc_hsdirs_changed(const hs_service_t *service,
const hs_service_descriptor_t *desc)
{
- int retval = 0;
+ int should_reupload = 0;
smartlist_t *responsible_dirs = smartlist_new();
- smartlist_t *b64_responsible_dirs = smartlist_new();
/* No desc upload has happened yet: it will happen eventually */
if (!desc->previous_hsdirs || !smartlist_len(desc->previous_hsdirs)) {
@@ -2383,32 +2385,24 @@ service_desc_hsdirs_changed(const hs_service_t *service,
hs_get_responsible_hsdirs(&desc->blinded_kp.pubkey, desc->time_period_num,
service->desc_next == desc, 0, responsible_dirs);
- /* Make a second list with their b64ed identity digests, so that we can
- * compare it with out previous list of hsdirs */
+ /* Check if any new hsdirs have been added to the responsible hsdirs set:
+ * Iterate over the list of new hsdirs, and reupload if any of them is not
+ * present in the list of previous hsdirs.
+ */
SMARTLIST_FOREACH_BEGIN(responsible_dirs, const routerstatus_t *, hsdir_rs) {
char b64_digest[BASE64_DIGEST_LEN+1] = {0};
digest_to_base64(b64_digest, hsdir_rs->identity_digest);
- smartlist_add_strdup(b64_responsible_dirs, b64_digest);
- } SMARTLIST_FOREACH_END(hsdir_rs);
- /* Sort this new smartlist so that we can compare it with the other one */
- smartlist_sort_strings(b64_responsible_dirs);
-
- /* Check whether the set of HSDirs changed */
- if (!smartlist_strings_eq(b64_responsible_dirs, desc->previous_hsdirs)) {
- log_info(LD_GENERAL, "Received new dirinfo and set of hsdirs changed!");
- retval = 1;
- } else {
- log_debug(LD_GENERAL, "No change in hsdir set!");
- }
+ if (!smartlist_contains_string(desc->previous_hsdirs, b64_digest)) {
+ should_reupload = 1;
+ break;
+ }
+ } SMARTLIST_FOREACH_END(hsdir_rs);
done:
smartlist_free(responsible_dirs);
- SMARTLIST_FOREACH(b64_responsible_dirs, char*, s, tor_free(s));
- smartlist_free(b64_responsible_dirs);
-
- return retval;
+ return should_reupload;
}
/* Return 1 if the given descriptor from the given service can be uploaded