aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2003-03-24 02:50:07 +0000
committerRoger Dingledine <arma@torproject.org>2003-03-24 02:50:07 +0000
commit9ac9db782aeacf62e2b625de0c629640f0ebdc25 (patch)
tree5c7965a9b5eeb0ab9423ce8ecca8306b8e630c13
parent9d03ae627d12d571ce19a841c469a99008523eed (diff)
downloadtor-9ac9db782aeacf62e2b625de0c629640f0ebdc25.tar
tor-9ac9db782aeacf62e2b625de0c629640f0ebdc25.tar.gz
fix rare race condition
if the directory is remade while an OR is handshaking, the directory needs to become dirty again when the handshake succeeds svn:r215
-rw-r--r--src/or/connection.c3
-rw-r--r--src/or/connection_or.c24
-rw-r--r--src/or/or.h1
3 files changed, 13 insertions, 15 deletions
diff --git a/src/or/connection.c b/src/or/connection.c
index 41d07293f..3cae0d42d 100644
--- a/src/or/connection.c
+++ b/src/or/connection.c
@@ -123,9 +123,6 @@ connection_t *connection_new(int type) {
return NULL;
}
}
- if(type == CONN_TYPE_OR) {
- directory_set_dirty();
- }
#ifdef USE_ZLIB
if (type == CONN_TYPE_AP || type == CONN_TYPE_EXIT) {
if (buf_new(&conn->z_outbuf, &conn->z_outbuflen, &conn->z_outbuf_datalen) < 0)
diff --git a/src/or/connection_or.c b/src/or/connection_or.c
index 7443f042f..ed3bd8be9 100644
--- a/src/or/connection_or.c
+++ b/src/or/connection_or.c
@@ -86,9 +86,8 @@ int connection_or_finished_flushing(connection_t *conn) {
case OR_CONN_STATE_CLIENT_SENDING_NONCE:
log(LOG_DEBUG,"connection_or_finished_flushing(): client finished sending nonce.");
conn_or_init_crypto(conn);
- conn->state = OR_CONN_STATE_OPEN;
- connection_init_timeval(conn);
- connection_watch_events(conn, POLLIN);
+ connection_or_set_open(conn);
+
return connection_process_inbuf(conn); /* in case there's anything waiting on it */
case OR_CONN_STATE_SERVER_SENDING_AUTH:
log(LOG_DEBUG,"connection_or_finished_flushing(): server finished sending auth.");
@@ -110,6 +109,13 @@ int connection_or_finished_flushing(connection_t *conn) {
/*********************/
+void connection_or_set_open(connection_t *conn) {
+ conn->state = OR_CONN_STATE_OPEN;
+ directory_set_dirty();
+ connection_init_timeval(conn);
+ connection_watch_events(conn, POLLIN);
+}
+
void conn_or_init_crypto(connection_t *conn) {
//int x;
unsigned char iv[16];
@@ -327,9 +333,7 @@ int or_handshake_op_finished_sending_keys(connection_t *conn) {
/* do crypto initialization, etc */
conn_or_init_crypto(conn);
- conn->state = OR_CONN_STATE_OPEN;
- connection_init_timeval(conn);
- connection_watch_events(conn, POLLIN); /* give it a default, tho the ap_handshake call may change it */
+ connection_or_set_open(conn);
ap_handshake_n_conn_open(conn); /* send the pending onions */
return 0;
}
@@ -532,9 +536,7 @@ int or_handshake_client_process_auth(connection_t *conn) {
/* it finished sending */
log(LOG_DEBUG,"or_handshake_client_process_auth(): Finished sending nonce.");
conn_or_init_crypto(conn);
- conn->state = OR_CONN_STATE_OPEN;
- connection_init_timeval(conn);
- connection_watch_events(conn, POLLIN);
+ connection_or_set_open(conn);
return connection_process_inbuf(conn); /* process the rest of the inbuf */
}
@@ -719,9 +721,7 @@ int or_handshake_server_process_nonce(connection_t *conn) {
log(LOG_DEBUG,"or_handshake_server_process_nonce() : Response valid. Authentication complete.");
conn_or_init_crypto(conn);
- conn->state = OR_CONN_STATE_OPEN;
- connection_init_timeval(conn);
- connection_watch_events(conn, POLLIN);
+ connection_or_set_open(conn);
return connection_process_inbuf(conn); /* process the rest of the inbuf */
}
diff --git a/src/or/or.h b/src/or/or.h
index 4871ee3b7..73ac995ad 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -649,6 +649,7 @@ int connection_op_handle_listener_read(connection_t *conn);
int connection_or_process_inbuf(connection_t *conn);
int connection_or_finished_flushing(connection_t *conn);
+void connection_or_set_open(connection_t *conn);
void conn_or_init_crypto(connection_t *conn);
int or_handshake_op_send_keys(connection_t *conn);