summaryrefslogtreecommitdiff
path: root/src/or/directory.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2011-06-22 13:57:19 -0400
committerNick Mathewson <nickm@torproject.org>2011-07-11 16:13:16 -0400
commita2ad31a92b85158f0dfa0a219ae5270e03b2ef02 (patch)
tree76ccdb01f75d5b364ebfaf9432a26e72ab99a5bf /src/or/directory.c
parenta21c4c657a1d06e2c4fc72a2f85400944d0e6460 (diff)
downloadtor-a2ad31a92b85158f0dfa0a219ae5270e03b2ef02.tar.gz
tor-a2ad31a92b85158f0dfa0a219ae5270e03b2ef02.zip
Split connection_about_to_close_connection into separate functions
This patch does NOTHING but: - move code - add declarations and includes as needed to make the new code work - declare the new functions.
Diffstat (limited to 'src/or/directory.c')
-rw-r--r--src/or/directory.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/or/directory.c b/src/or/directory.c
index 17413edeb3..c0d4c22be3 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -2301,6 +2301,28 @@ connection_dir_process_inbuf(dir_connection_t *conn)
return 0;
}
+/** Called when we're about to finally unlink and free a directory connection:
+ * perform necessary accounting and cleanup */
+void
+connection_dir_about_to_close(dir_connection_t *dir_conn)
+{
+ connection_t *conn = TO_CONN(dir_conn);
+
+ if (conn->state < DIR_CONN_STATE_CLIENT_FINISHED) {
+ /* It's a directory connection and connecting or fetching
+ * failed: forget about this router, and maybe try again. */
+ connection_dir_request_failed(dir_conn);
+ }
+ /* If we were trying to fetch a v2 rend desc and did not succeed,
+ * retry as needed. (If a fetch is successful, the connection state
+ * is changed to DIR_PURPOSE_HAS_FETCHED_RENDDESC to mark that
+ * refetching is unnecessary.) */
+ if (conn->purpose == DIR_PURPOSE_FETCH_RENDDESC_V2 &&
+ dir_conn->rend_data &&
+ strlen(dir_conn->rend_data->onion_address) == REND_SERVICE_ID_LEN_BASE32)
+ rend_client_refetch_v2_renddesc(dir_conn->rend_data);
+}
+
/** Create an http response for the client <b>conn</b> out of
* <b>status</b> and <b>reason_phrase</b>. Write it to <b>conn</b>.
*/