[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/master] prop224: hs_time_between_tp_and_srv() -> hs_in_period_between_tp_and_srv()



commit e7bdb9eedce5edd014090883c222eb474648a87b
Author: George Kadianakis <desnacked@xxxxxxxxxx>
Date:   Fri Sep 8 19:06:20 2017 +0300

    prop224: hs_time_between_tp_and_srv() -> hs_in_period_between_tp_and_srv()
    
    Conflicts:
            src/or/nodelist.c
---
 src/or/hs_client.c        |  2 +-
 src/or/hs_common.c        |  2 +-
 src/or/hs_common.h        |  2 +-
 src/or/hs_service.c       |  4 ++--
 src/or/nodelist.c         |  7 ++++---
 src/test/test_hs_common.c | 17 +++++++++--------
 6 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/src/or/hs_client.c b/src/or/hs_client.c
index 4f467c7ec..c9709b4d2 100644
--- a/src/or/hs_client.c
+++ b/src/or/hs_client.c
@@ -183,7 +183,7 @@ pick_hsdir_v3(const ed25519_public_key_t *onion_identity_pk)
   }
 
   /* Get responsible hsdirs of service for this time period */
-  is_new_tp = hs_time_between_tp_and_srv(NULL, time(NULL));
+  is_new_tp = hs_in_period_between_tp_and_srv(NULL, time(NULL));
   hs_get_responsible_hsdirs(&blinded_pubkey, current_time_period,
                             is_new_tp, 1, responsible_hsdirs);
 
diff --git a/src/or/hs_common.c b/src/or/hs_common.c
index e5ea37954..291d8ae8d 100644
--- a/src/or/hs_common.c
+++ b/src/or/hs_common.c
@@ -1049,7 +1049,7 @@ hs_build_blinded_keypair(const ed25519_keypair_t *kp,
  *    +------------------------------------------------------------------+
  */
 MOCK_IMPL(int,
-hs_time_between_tp_and_srv, (const networkstatus_t *consensus, time_t now))
+hs_in_period_between_tp_and_srv,(const networkstatus_t *consensus, time_t now))
 {
   time_t valid_after;
   time_t srv_start_time, tp_start_time;
diff --git a/src/or/hs_common.h b/src/or/hs_common.h
index b2e3c836d..77b4e6544 100644
--- a/src/or/hs_common.h
+++ b/src/or/hs_common.h
@@ -204,7 +204,7 @@ time_t hs_get_start_time_of_next_time_period(time_t now);
 
 link_specifier_t *hs_link_specifier_dup(const link_specifier_t *lspec);
 
-MOCK_DECL(int, hs_time_between_tp_and_srv,
+MOCK_DECL(int, hs_in_period_between_tp_and_srv,
           (const networkstatus_t *consensus, time_t now));
 
 uint8_t *hs_get_current_srv(uint64_t time_period_num,
diff --git a/src/or/hs_service.c b/src/or/hs_service.c
index 41154d270..8f5da2b63 100644
--- a/src/or/hs_service.c
+++ b/src/or/hs_service.c
@@ -1398,7 +1398,7 @@ build_descriptors_for_new_service(hs_service_t *service, time_t now)
    * TP#1 and next TP#2.
    */
 
-  if (hs_time_between_tp_and_srv(NULL, now)) {
+  if (hs_in_period_between_tp_and_srv(NULL, now)) {
     /* Case B from the above, inside of the new time period. */
     current_desc_tp = hs_get_previous_time_period_num(0); /* TP#1 */
     next_desc_tp = hs_get_time_period_num(0);             /* TP#2 */
@@ -2390,7 +2390,7 @@ upload_descriptor_to_all(const hs_service_t *service,
 
   /* Do we have a new TP that is are we between a new time period and the next
    * SRV creation? */
-  is_new_tp = hs_time_between_tp_and_srv(NULL, approx_time());
+  is_new_tp = hs_in_period_between_tp_and_srv(NULL, approx_time());
   /* Get our list of responsible HSDir. */
   responsible_dirs = smartlist_new();
   /* The parameter 0 means that we aren't a client so tell the function to use
diff --git a/src/or/nodelist.c b/src/or/nodelist.c
index 674533b22..29ef835fb 100644
--- a/src/or/nodelist.c
+++ b/src/or/nodelist.c
@@ -210,7 +210,8 @@ node_set_hsdir_index(node_t *node, const networkstatus_t *ns)
   /* We always use the current time period for fetching descs */
   fetch_tp = current_time_period_num;
 
-  if (hs_time_between_tp_and_srv(ns, now)) {
+  /* Now extract the needed SRVs and time periods for building hsdir indices */
+  if (hs_in_period_between_tp_and_srv(ns, now)) {
     fetch_srv = hs_get_current_srv(fetch_tp, ns);
 
     store_first_tp = hs_get_previous_time_period_num(0);
@@ -233,7 +234,7 @@ node_set_hsdir_index(node_t *node, const networkstatus_t *ns)
 
   /* If we are in the time segment between SRV#N and TP#N, the fetch index is
      the same as the first store index */
-  if (!hs_time_between_tp_and_srv(ns, now)) {
+  if (!hs_in_period_between_tp_and_srv(ns, now)) {
     memcpy(node->hsdir_index->store_first, node->hsdir_index->fetch,
            sizeof(node->hsdir_index->store_first));
   } else {
@@ -243,7 +244,7 @@ node_set_hsdir_index(node_t *node, const networkstatus_t *ns)
 
   /* If we are in the time segment between TP#N and SRV#N+1, the fetch index is
      the same as the second store index */
-  if (hs_time_between_tp_and_srv(ns, now)) {
+  if (hs_in_period_between_tp_and_srv(ns, now)) {
     memcpy(node->hsdir_index->store_second, node->hsdir_index->fetch,
            sizeof(node->hsdir_index->store_second));
   } else {
diff --git a/src/test/test_hs_common.c b/src/test/test_hs_common.c
index a2ebe03d7..4b5b0fe3e 100644
--- a/src/test/test_hs_common.c
+++ b/src/test/test_hs_common.c
@@ -786,27 +786,27 @@ test_time_between_tp_and_srv(void *arg)
 
   ret = parse_rfc1123_time("Sat, 26 Oct 1985 00:00:00 UTC", &ns.valid_after);
   tt_int_op(ret, OP_EQ, 0);
-  ret = hs_time_between_tp_and_srv(&ns, 0);
+  ret = hs_in_period_between_tp_and_srv(&ns, 0);
   tt_int_op(ret, OP_EQ, 0);
 
   ret = parse_rfc1123_time("Sat, 26 Oct 1985 11:00:00 UTC", &ns.valid_after);
   tt_int_op(ret, OP_EQ, 0);
-  ret = hs_time_between_tp_and_srv(&ns, 0);
+  ret = hs_in_period_between_tp_and_srv(&ns, 0);
   tt_int_op(ret, OP_EQ, 0);
 
   ret = parse_rfc1123_time("Sat, 26 Oct 1985 12:00:00 UTC", &ns.valid_after);
   tt_int_op(ret, OP_EQ, 0);
-  ret = hs_time_between_tp_and_srv(&ns, 0);
+  ret = hs_in_period_between_tp_and_srv(&ns, 0);
   tt_int_op(ret, OP_EQ, 1);
 
   ret = parse_rfc1123_time("Sat, 26 Oct 1985 23:00:00 UTC", &ns.valid_after);
   tt_int_op(ret, OP_EQ, 0);
-  ret = hs_time_between_tp_and_srv(&ns, 0);
+  ret = hs_in_period_between_tp_and_srv(&ns, 0);
   tt_int_op(ret, OP_EQ, 1);
 
   ret = parse_rfc1123_time("Sat, 26 Oct 1985 00:00:00 UTC", &ns.valid_after);
   tt_int_op(ret, OP_EQ, 0);
-  ret = hs_time_between_tp_and_srv(&ns, 0);
+  ret = hs_in_period_between_tp_and_srv(&ns, 0);
   tt_int_op(ret, OP_EQ, 0);
 
  done:
@@ -1065,7 +1065,8 @@ typedef struct reachability_cfg_t {
 
   /* Is the client and service expected to be in a new time period. After
    * setting the consensus time, the reachability test checks
-   * hs_time_between_tp_and_srv() and test the returned value against this. */
+   * hs_in_period_between_tp_and_srv() and test the returned value against
+   * this. */
   unsigned int service_in_new_tp;
   unsigned int client_in_new_tp;
 
@@ -1300,9 +1301,9 @@ run_reachability_scenario(const reachability_cfg_t *cfg, int num_scenario)
                       &mock_client_ns->fresh_until);
 
   /* New time period checks for this scenario. */
-  tt_int_op(hs_time_between_tp_and_srv(mock_service_ns, 0), OP_EQ,
+  tt_int_op(hs_in_period_between_tp_and_srv(mock_service_ns, 0), OP_EQ,
             cfg->service_in_new_tp);
-  tt_int_op(hs_time_between_tp_and_srv(mock_client_ns, 0), OP_EQ,
+  tt_int_op(hs_in_period_between_tp_and_srv(mock_client_ns, 0), OP_EQ,
             cfg->client_in_new_tp);
 
   /* Set the SRVs for this scenario. */



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits