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.");
/*********************/
+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];
/* 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;
}
/* 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 */
}
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 */
}