[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] backward the patch to work better when we"ve been offline r...
- To: or-cvs@xxxxxxxxxxxxx
- Subject: [or-cvs] backward the patch to work better when we"ve been offline r...
- From: arma@xxxxxxxx (Roger Dingledine)
- Date: Sun, 9 Jan 2005 23:36:50 -0500 (EST)
- Delivered-to: archiver@seul.org
- Delivered-to: or-cvs-outgoing@seul.org
- Delivered-to: or-cvs@seul.org
- Delivery-date: Sun, 09 Jan 2005 23:37:18 -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/0091/tor/src/or
Modified Files:
Tag: tor-0_0_9-patches
circuituse.c directory.c main.c or.h
Log Message:
backward the patch to work better when we've been offline recently
Index: circuituse.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/circuituse.c,v
retrieving revision 1.38
retrieving revision 1.38.2.1
diff -u -d -r1.38 -r1.38.2.1
--- circuituse.c 13 Dec 2004 00:44:38 -0000 1.38
+++ circuituse.c 10 Jan 2005 04:36:47 -0000 1.38.2.1
@@ -717,6 +717,19 @@
return 1; /* we're happy */
}
+ if (!has_fetched_directory) {
+ if (!connection_get_by_type(CONN_TYPE_DIR)) {
+ log_fn(LOG_NOTICE,"Application request when we're believed to be offline. Optimistically trying again.");
+ directory_get_from_dirserver(DIR_PURPOSE_FETCH_DIR, NULL, 1);
+ }
+ /* the stream will be dealt with when has_fetched_directory becomes
+ * 1, or when all directory attempts fail and directory_all_unreachable()
+ * kills it.
+ */
+ return 0;
+ }
+
+
/* Do we need to check exit policy? */
if (!is_resolve && !connection_edge_is_rendezvous_stream(conn)) {
addr = client_dns_lookup_entry(conn->socks_request->address);
Index: directory.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/directory.c,v
retrieving revision 1.181.2.5
retrieving revision 1.181.2.6
diff -u -d -r1.181.2.5 -r1.181.2.6
--- directory.c 6 Jan 2005 21:04:59 -0000 1.181.2.5
+++ directory.c 10 Jan 2005 04:36:47 -0000 1.181.2.6
@@ -184,7 +184,8 @@
else if (ds)
directory_initiate_command_trusted_dir(ds, purpose, resource, NULL, 0);
else {
- log_fn(LOG_WARN,"No running dirservers known. Not trying. (purpose %d)", purpose);
+ log_fn(LOG_NOTICE,"No running dirservers known. Not trying. (purpose %d)", purpose);
+ directory_all_unreachable(time(NULL)); /* remember we tried them all and failed. */
}
}
Index: main.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/main.c,v
retrieving revision 1.407.2.3
retrieving revision 1.407.2.4
diff -u -d -r1.407.2.3 -r1.407.2.4
--- main.c 6 Jan 2005 07:40:30 -0000 1.407.2.3
+++ main.c 10 Jan 2005 04:36:47 -0000 1.407.2.4
@@ -380,6 +380,26 @@
}
}
+/** We've just tried every dirserver we know about, and none of
+ * them were reachable. Assume the network is down. Change state
+ * so next time an application connection arrives we'll delay it
+ * and try another directory fetch. Kill off all the circuit_wait
+ * streams that are waiting now, since they will all timeout anyway.
+ */
+void directory_all_unreachable(time_t now) {
+ connection_t *conn;
+
+ has_fetched_directory=0;
+
+ while ((conn = connection_get_by_type_state(CONN_TYPE_AP,
+ AP_CONN_STATE_CIRCUIT_WAIT))) {
+ conn->has_sent_end = 1; /* it's not connected anywhere, so no need to end */
+ log_fn(LOG_NOTICE,"Network down? Failing connection to '%s'.",
+ conn->socks_request->address);
+ connection_mark_for_close(conn);
+ }
+}
+
/** This function is called whenever we successfully pull down a directory */
void directory_has_arrived(time_t now) {
or_options_t *options = get_options();
Index: or.h
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/or.h,v
retrieving revision 1.508.2.6
retrieving revision 1.508.2.7
diff -u -d -r1.508.2.6 -r1.508.2.7
--- or.h 6 Jan 2005 20:30:09 -0000 1.508.2.6
+++ or.h 10 Jan 2005 04:36:47 -0000 1.508.2.7
@@ -1381,7 +1381,9 @@
void connection_stop_writing(connection_t *conn);
void connection_start_writing(connection_t *conn);
+void directory_all_unreachable(time_t now);
void directory_has_arrived(time_t now);
+
int authdir_mode(or_options_t *options);
int clique_mode(or_options_t *options);
int server_mode(or_options_t *options);