[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] when a client asks us for a dir mirror and we don"t have one,
- To: or-cvs@xxxxxxxxxxxxx
- Subject: [or-cvs] when a client asks us for a dir mirror and we don"t have one,
- From: arma@xxxxxxxx (Roger Dingledine)
- Date: Thu, 10 Feb 2005 01:31:42 -0500 (EST)
- Delivered-to: archiver@seul.org
- Delivered-to: or-cvs-outgoing@seul.org
- Delivered-to: or-cvs@seul.org
- Delivery-date: Thu, 10 Feb 2005 01:32:09 -0500
- Reply-to: or-dev@xxxxxxxxxxxxx
- Sender: owner-or-cvs@xxxxxxxxxxxxx
Update of /home2/or/cvsroot/tor/src/or
In directory moria.mit.edu:/home2/arma/work/onion/cvs/tor/src/or
Modified Files:
connection.c directory.c
Log Message:
when a client asks us for a dir mirror and we don't have one,
launch an attempt to get a fresh one.
Index: connection.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/connection.c,v
retrieving revision 1.324
retrieving revision 1.325
diff -u -d -r1.324 -r1.325
--- connection.c 9 Feb 2005 23:54:30 -0000 1.324
+++ connection.c 10 Feb 2005 06:31:34 -0000 1.325
@@ -1256,6 +1256,23 @@
return NULL;
}
+/** Return a connection of type <b>type</b> that has purpose <b>purpose</b>,
+ * and that is not marked for close.
+ */
+connection_t *connection_get_by_type_purpose(int type, int purpose) {
+ int i, n;
+ connection_t *conn;
+ connection_t **carray;
+
+ get_connection_array(&carray,&n);
+ for (i=0;i<n;i++) {
+ conn = carray[i];
+ if (conn->type == type && conn->purpose == purpose && !conn->marked_for_close)
+ return conn;
+ }
+ return NULL;
+}
+
/** Return the connection of type <b>type</b> that is in state
* <b>state</b>, that was written to least recently, and that is not
* marked for close.
Index: directory.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/directory.c,v
retrieving revision 1.210
retrieving revision 1.211
diff -u -d -r1.210 -r1.211
--- directory.c 5 Feb 2005 21:42:45 -0000 1.210
+++ directory.c 10 Feb 2005 06:31:34 -0000 1.211
@@ -876,6 +876,9 @@
if (dlen == 0) {
log_fn(LOG_NOTICE,"Client asked for the mirrored directory, but we don't have a good one yet. Sending 503 Dir not available.");
write_http_status_line(conn, 503, "Directory unavailable");
+ /* try to get a new one now */
+ if (!connection_get_by_type_purpose(CONN_TYPE_DIR, DIR_PURPOSE_FETCH_DIR))
+ directory_get_from_dirserver(DIR_PURPOSE_FETCH_DIR, NULL, 1);
return 0;
}
@@ -898,6 +901,10 @@
dlen = dirserv_get_runningrouters(&cp, deflated);
if (!dlen) { /* we failed to create/cache cp */
write_http_status_line(conn, 503, "Directory unavailable");
+ /* try to get a new one now */
+ if (!connection_get_by_type_purpose(CONN_TYPE_DIR,
+ DIR_PURPOSE_FETCH_RUNNING_LIST))
+ directory_get_from_dirserver(DIR_PURPOSE_FETCH_RUNNING_LIST, NULL, 1);
return 0;
}