diff options
author | Roger Dingledine <arma@torproject.org> | 2005-05-23 05:20:52 +0000 |
---|---|---|
committer | Roger Dingledine <arma@torproject.org> | 2005-05-23 05:20:52 +0000 |
commit | 040a748d87c7f7d1e81317498efa3ba0833303f7 (patch) | |
tree | b2800c06fcdbb771254bffb1b90a03ba1de04b99 /src/or/directory.c | |
parent | 36a21de66d5078fd01e8378f17dcbd4738aaacd4 (diff) | |
download | tor-040a748d87c7f7d1e81317498efa3ba0833303f7.tar tor-040a748d87c7f7d1e81317498efa3ba0833303f7.tar.gz |
i screwed up the dirport reachability testing when we don't yet
have a cached version of the directory. hopefully now fixed.
svn:r4284
Diffstat (limited to 'src/or/directory.c')
-rw-r--r-- | src/or/directory.c | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/src/or/directory.c b/src/or/directory.c index 3a4da0c04..fcea980ea 100644 --- a/src/or/directory.c +++ b/src/or/directory.c @@ -903,6 +903,28 @@ write_http_status_line(connection_t *conn, int status, 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 @@ directory_handle_command_get(connection_t *conn, char *headers, 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 @@ directory_handle_command_get(connection_t *conn, char *headers, 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; } |