[or-cvs] r17028: {tor} Make rend_cache_store() use the same return error codes as i (tor/trunk/src/or)

arma at seul.org arma at seul.org
Thu Oct 2 07:32:14 UTC 2008


Author: arma
Date: 2008-10-02 03:32:13 -0400 (Thu, 02 Oct 2008)
New Revision: 17028

Modified:
   tor/trunk/src/or/directory.c
   tor/trunk/src/or/rendcommon.c
Log:
Make rend_cache_store() use the same return error codes as its v2
equivalent: I got a lonely "Failed to fetch rendezvous descriptor."
in my log file, even when the connection worked.


Modified: tor/trunk/src/or/directory.c
===================================================================
--- tor/trunk/src/or/directory.c	2008-10-02 01:59:46 UTC (rev 17027)
+++ tor/trunk/src/or/directory.c	2008-10-02 07:32:13 UTC (rev 17028)
@@ -1946,15 +1946,16 @@
              (int)body_len, status_code, escaped(reason));
     switch (status_code) {
       case 200:
-        if (rend_cache_store(body, body_len, 0) < 0) {
-          log_warn(LD_REND,"Failed to fetch rendezvous descriptor.");
+        if (rend_cache_store(body, body_len, 0) < -1) {
+          log_warn(LD_REND,"Failed to parse rendezvous descriptor.");
           /* Any pending rendezvous attempts will notice when
            * connection_about_to_close_connection()
            * cleans this dir conn up. */
           /* We could retry. But since v0 descriptors are going out of
            * style, it isn't worth the hassle. We'll do better in v2. */
         } else {
-          /* success. notify pending connections about this. */
+          /* Success, or at least there's a v2 descriptor already
+           * present. Notify pending connections about this. */
           conn->_base.purpose = DIR_PURPOSE_HAS_FETCHED_RENDDESC;
           rend_client_desc_trynow(conn->rend_data->onion_address, -1);
         }

Modified: tor/trunk/src/or/rendcommon.c
===================================================================
--- tor/trunk/src/or/rendcommon.c	2008-10-02 01:59:46 UTC (rev 17027)
+++ tor/trunk/src/or/rendcommon.c	2008-10-02 07:32:13 UTC (rev 17028)
@@ -1027,9 +1027,12 @@
  * If we are acting as client due to the published flag and have any v2
  * descriptor with the same ID, reject this one in order to not get
  * confused with having both versions for the same service.
- * Return -1 if it's malformed or otherwise rejected; return 0 if
- * it's the same or older than one we've already got; return 1 if
- * it's novel. The published flag tells us if we store the descriptor
+ *
+ * Return -2 if it's malformed or otherwise rejected; return -1 if we
+ * already have a v2 descriptor here; return 0 if it's the same or older
+ * than one we've already got; return 1 if it's novel.
+ *
+ * The published flag tells us if we store the descriptor
  * in our role as directory (1) or if we cache it as client (0).
  */
 int
@@ -1045,25 +1048,25 @@
   parsed = rend_parse_service_descriptor(desc,desc_len);
   if (!parsed) {
     log_warn(LD_PROTOCOL,"Couldn't parse service descriptor.");
-    return -1;
+    return -2;
   }
   if (rend_get_service_id(parsed->pk, query)<0) {
     log_warn(LD_BUG,"Couldn't compute service ID.");
     rend_service_descriptor_free(parsed);
-    return -1;
+    return -2;
   }
   now = time(NULL);
   if (parsed->timestamp < now-REND_CACHE_MAX_AGE-REND_CACHE_MAX_SKEW) {
     log_fn(LOG_PROTOCOL_WARN, LD_REND,
            "Service descriptor %s is too old.", safe_str(query));
     rend_service_descriptor_free(parsed);
-    return -1;
+    return -2;
   }
   if (parsed->timestamp > now+REND_CACHE_MAX_SKEW) {
     log_fn(LOG_PROTOCOL_WARN, LD_REND,
            "Service descriptor %s is too far in the future.", safe_str(query));
     rend_service_descriptor_free(parsed);
-    return -1;
+    return -2;
   }
   /* Do we have a v2 descriptor and fetched this descriptor as a client? */
   tor_snprintf(key, sizeof(key), "2%s", query);



More information about the tor-commits mailing list