[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] bugfix: you mean we"re supposed to reuse fresh descriptors ...
- To: or-cvs@freehaven.net
- Subject: [or-cvs] bugfix: you mean we"re supposed to reuse fresh descriptors ...
- From: arma@seul.org (Roger Dingledine)
- Date: Sun, 18 Apr 2004 05:04:41 -0400 (EDT)
- Delivered-to: archiver@seul.org
- Delivered-to: or-cvs-outgoing@seul.org
- Delivered-to: or-cvs@seul.org
- Delivery-date: Sun, 18 Apr 2004 05:05:06 -0400
- Reply-to: or-dev@freehaven.net
- Sender: owner-or-cvs@freehaven.net
Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/home2/arma/work/onion/cvs/src/or
Modified Files:
connection_edge.c
Log Message:
bugfix: you mean we're supposed to reuse fresh descriptors and
refetch stale ones, not reuse stale ones and refetch fresh ones?
Index: connection_edge.c
===================================================================
RCS file: /home/or/cvsroot/src/or/connection_edge.c,v
retrieving revision 1.174
retrieving revision 1.175
diff -u -d -r1.174 -r1.175
--- connection_edge.c 18 Apr 2004 07:37:15 -0000 1.174
+++ connection_edge.c 18 Apr 2004 09:04:37 -0000 1.175
@@ -746,20 +746,35 @@
} else {
/* it's a hidden-service request */
rend_cache_entry_t *entry;
+ int r;
strcpy(conn->rend_query, socks->address); /* this strcpy is safe -RD */
log_fn(LOG_INFO,"Got a hidden service request for ID '%s'", conn->rend_query);
/* see if we already have it cached */
- if (rend_cache_lookup_entry(conn->rend_query, &entry) == 1 &&
-#define NUM_SECONDS_BEFORE_REFETCH (60*15)
- entry->received + NUM_SECONDS_BEFORE_REFETCH < time(NULL)) {
- conn->state = AP_CONN_STATE_CIRCUIT_WAIT;
- return connection_ap_handshake_attach_circuit(conn);
- } else {
+ r = rend_cache_lookup_entry(conn->rend_query, &entry);
+ if(r<0) {
+ log_fn(LOG_WARN,"Invalid service descriptor %s", conn->rend_query);
+ return -1;
+ }
+ if(r==0) {
conn->state = AP_CONN_STATE_RENDDESC_WAIT;
+ log_fn(LOG_INFO, "Unknown descriptor %s. Fetching.", conn->rend_query);
rend_client_refetch_renddesc(conn->rend_query);
return 0;
}
+ if(r>0) {
+#define NUM_SECONDS_BEFORE_REFETCH (60*15)
+ if(time(NULL) - entry->received < NUM_SECONDS_BEFORE_REFETCH) {
+ conn->state = AP_CONN_STATE_CIRCUIT_WAIT;
+ log_fn(LOG_INFO, "Descriptor is here and fresh enough. Great.");
+ return connection_ap_handshake_attach_circuit(conn);
+ } else {
+ conn->state = AP_CONN_STATE_RENDDESC_WAIT;
+ log_fn(LOG_INFO, "Stale descriptor %s. Refetching.", conn->rend_query);
+ rend_client_refetch_renddesc(conn->rend_query);
+ return 0;
+ }
+ }
}
return 0;
}