aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2008-10-02 07:32:13 +0000
committerRoger Dingledine <arma@torproject.org>2008-10-02 07:32:13 +0000
commite7f5a07ff432d4db0caf2009d36766f4f448da32 (patch)
treee42fa5bc2495934be0851bf8f5196ac39453352a
parente24b812a32cd3e9281670443e6a02952315b0234 (diff)
downloadtor-e7f5a07ff432d4db0caf2009d36766f4f448da32.tar
tor-e7f5a07ff432d4db0caf2009d36766f4f448da32.tar.gz
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. svn:r17028
-rw-r--r--src/or/directory.c7
-rw-r--r--src/or/rendcommon.c17
2 files changed, 14 insertions, 10 deletions
diff --git a/src/or/directory.c b/src/or/directory.c
index 9dfc80942..5bd85bab7 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -1946,15 +1946,16 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
(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);
}
diff --git a/src/or/rendcommon.c b/src/or/rendcommon.c
index 343c43d7d..ccd52fcee 100644
--- a/src/or/rendcommon.c
+++ b/src/or/rendcommon.c
@@ -1027,9 +1027,12 @@ rend_cache_lookup_v2_desc_as_dir(const char *desc_id, const char **desc)
* 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 @@ rend_cache_store(const char *desc, size_t desc_len, int published)
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);