]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Set published_out for consensus cache entries in spooled_resource_estimate_size().
authorAlexander Færøy <ahf@0x90.dk>
Fri, 23 Jun 2017 23:55:54 +0000 (23:55 +0000)
committerNick Mathewson <nickm@torproject.org>
Tue, 27 Jun 2017 22:25:48 +0000 (18:25 -0400)
This patch ensures that the published_out output parameter is set to the
current consensus cache entry's "valid after" field.

See: https://bugs.torproject.org/22702

src/or/consdiffmgr.c
src/or/consdiffmgr.h
src/or/dirserv.c

index 2af104733b6830b4a41184fa9876bd4733f22d83..4036f665f9b184efa166b1f36cc1573ec622a625 100644 (file)
@@ -1840,3 +1840,21 @@ consensus_cache_entry_get_valid_until(const consensus_cache_entry_t *ent,
     return 0;
 }
 
+/** Read the valid after timestamp from the cached object <b>ent</b> into
+ * *<b>out</b> and return 0, or return -1 if no such time was recorded. */
+int
+consensus_cache_entry_get_valid_after(const consensus_cache_entry_t *ent,
+                                      time_t *out)
+{
+  tor_assert(ent);
+  tor_assert(out);
+
+  const char *s;
+  s = consensus_cache_entry_get_value(ent, LABEL_VALID_AFTER);
+
+  if (s == NULL || parse_iso_time_nospace(s, out) < 0)
+    return -1;
+  else
+    return 0;
+}
+
index fe4f9ee239341e0d17e44e7bc5ef2046bdf14ff2..079f9fe2d27b1ed0c0a2343fcd84d5117a2514a2 100644 (file)
@@ -44,6 +44,9 @@ int consensus_cache_entry_get_fresh_until(
 int consensus_cache_entry_get_valid_until(
                                   const struct consensus_cache_entry_t *ent,
                                   time_t *out);
+int consensus_cache_entry_get_valid_after(
+                                  const struct consensus_cache_entry_t *ent,
+                                  time_t *out);
 
 void consdiffmgr_rescan(void);
 int consdiffmgr_cleanup(void);
index 408f58b22b5958246d6aa9b361b1c815eeb01869..4954471c6a8aa6eb5c8037a32a84914e004cf66e 100644 (file)
@@ -14,6 +14,7 @@
 #include "connection.h"
 #include "connection_or.h"
 #include "conscache.h"
+#include "consdiffmgr.h"
 #include "control.h"
 #include "directory.h"
 #include "dirserv.h"
@@ -3518,6 +3519,11 @@ spooled_resource_estimate_size(const spooled_resource_t *spooled,
   } else {
     cached_dir_t *cached;
     if (spooled->consensus_cache_entry) {
+      if (published_out) {
+        consensus_cache_entry_get_valid_after(
+            spooled->consensus_cache_entry, published_out);
+      }
+
       return spooled->cce_len;
     }
     if (spooled->cached_dir_ref) {