[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] i screwed up the dirport reachability testing when we don"t...
Update of /home2/or/cvsroot/tor/src/or
In directory moria:/home/arma/work/onion/cvs/tor/src/or
Modified Files:
connection.c directory.c main.c or.h router.c
Log Message:
i screwed up the dirport reachability testing when we don't yet
have a cached version of the directory. hopefully now fixed.
Index: connection.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/connection.c,v
retrieving revision 1.372
retrieving revision 1.373
diff -u -d -r1.372 -r1.373
--- connection.c 21 May 2005 00:15:23 -0000 1.372
+++ connection.c 23 May 2005 05:20:52 -0000 1.373
@@ -1437,23 +1437,6 @@
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.228
retrieving revision 1.229
diff -u -d -r1.228 -r1.229
--- directory.c 20 May 2005 08:51:45 -0000 1.228
+++ directory.c 23 May 2005 05:20:52 -0000 1.229
@@ -903,6 +903,28 @@
connection_write_to_buf(buf, strlen(buf), conn);
}
+/** Helper function: return 1 if there are any dir conns of purpose
+ * <b>purpose</b> that are going elsewhere than our own ORPort/Dirport.
+ * Else return 0.
+ */
+static int
+already_fetching_directory(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 == CONN_TYPE_DIR &&
+ conn->purpose == purpose &&
+ !conn->marked_for_close &&
+ !router_digest_is_me(conn->identity_digest))
+ return 1;
+ }
+ return 0;
+}
+
/** Helper function: called when a dirserver gets a complete HTTP GET
* request. Look for a request for a directory or for a rendezvous
* service descriptor. On finding one, write a response into
@@ -938,7 +960,7 @@
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))
+ if (!already_fetching_directory(DIR_PURPOSE_FETCH_DIR))
directory_get_from_dirserver(DIR_PURPOSE_FETCH_DIR, NULL, 1);
return 0;
}
@@ -963,8 +985,7 @@
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))
+ if (!already_fetching_directory(DIR_PURPOSE_FETCH_RUNNING_LIST))
directory_get_from_dirserver(DIR_PURPOSE_FETCH_RUNNING_LIST, NULL, 1);
return 0;
}
Index: main.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/main.c,v
retrieving revision 1.499
retrieving revision 1.500
diff -u -d -r1.499 -r1.500
--- main.c 23 May 2005 02:31:53 -0000 1.499
+++ main.c 23 May 2005 05:20:52 -0000 1.500
@@ -523,12 +523,8 @@
if (server_mode(options) && identity_digest) {
/* if this is us, then our dirport is reachable */
- routerinfo_t *router = router_get_by_digest(identity_digest);
- if (!router) // XXX
- log_fn(LOG_WARN,"Bug: router_get_by_digest doesn't find me.");
- if (router && router_is_me(router)) {
+ if (router_digest_is_me(identity_digest))
router_dirport_found_reachable();
- }
}
if (server_mode(options) &&
Index: or.h
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/or.h,v
retrieving revision 1.609
retrieving revision 1.610
diff -u -d -r1.609 -r1.610
--- or.h 20 May 2005 08:51:45 -0000 1.609
+++ or.h 23 May 2005 05:20:52 -0000 1.610
@@ -1304,7 +1304,6 @@
connection_t *connection_get_by_type(int type);
connection_t *connection_get_by_type_state(int type, int state);
-connection_t *connection_get_by_type_purpose(int type, int purpose);
connection_t *connection_get_by_type_state_lastwritten(int type, int state);
connection_t *connection_get_by_type_state_rendquery(int type, int state, const char *rendquery);
@@ -1752,6 +1751,7 @@
int router_compare_to_my_exit_policy(connection_t *conn);
routerinfo_t *router_get_my_routerinfo(void);
const char *router_get_my_descriptor(void);
+int router_digest_is_me(const char *digest);
int router_is_me(routerinfo_t *router);
int router_rebuild_descriptor(int force);
int router_dump_router_to_string(char *s, size_t maxlen, routerinfo_t *router,
Index: router.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/router.c,v
retrieving revision 1.174
retrieving revision 1.175
diff -u -d -r1.174 -r1.175
--- router.c 17 May 2005 17:01:36 -0000 1.174
+++ router.c 23 May 2005 05:20:52 -0000 1.175
@@ -593,18 +593,22 @@
desc_routerinfo->exit_policy) != ADDR_POLICY_ACCEPTED;
}
-/** Return true iff <b>router</b> has the same nickname as this OR. (For an
- * OP, always returns false.)
- */
-int router_is_me(routerinfo_t *router)
+/** Return true iff I'm a server and <b>digest</b> is equal to
+ * my identity digest. */
+int router_digest_is_me(const char *digest)
{
routerinfo_t *me = router_get_my_routerinfo();
- tor_assert(router);
- if (!me || memcmp(me->identity_digest, router->identity_digest, DIGEST_LEN))
+ if (!me || memcmp(me->identity_digest, digest, DIGEST_LEN))
return 0;
return 1;
}
+/** A wrapper around router_digest_is_me(). */
+int router_is_me(routerinfo_t *router)
+{
+ return router_digest_is_me(router->identity_digest);
+}
+
/** Return a routerinfo for this OR, rebuilding a fresh one if
* necessary. Return NULL on error, or if called on an OP. */
routerinfo_t *router_get_my_routerinfo(void)