diff options
author | Nick Mathewson <nickm@torproject.org> | 2003-11-11 02:41:31 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2003-11-11 02:41:31 +0000 |
commit | dafb0e6a6eddc8b0fbf6de4292d49a311b2e712a (patch) | |
tree | 4960fd86da6eaff71d83c2c9a5e00f87ba33d0a4 /src/or/connection.c | |
parent | 894b1bc5d05ba263874d4b24caca44d2b6a2ae38 (diff) | |
download | tor-dafb0e6a6eddc8b0fbf6de4292d49a311b2e712a.tar tor-dafb0e6a6eddc8b0fbf6de4292d49a311b2e712a.tar.gz |
Make AP connections wait for a circuit if none exists.
Also:
- Refactor socks request into a separate struct
- Add a separate 'waiting for circuit' state to AP connections
between 'waiting for socks' and 'open'.
Arma: can you check out the XXX's I've added to connection_edge? I may
be mishandling some async and close logic.
svn:r783
Diffstat (limited to 'src/or/connection.c')
-rw-r--r-- | src/or/connection.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/or/connection.c b/src/or/connection.c index 685c5b1ae..b8706e410 100644 --- a/src/or/connection.c +++ b/src/or/connection.c @@ -85,6 +85,10 @@ connection_t *connection_new(int type) { conn->inbuf = buf_new(); conn->outbuf = buf_new(); } + if (type == CONN_TYPE_AP) { + conn->socks_request = tor_malloc(sizeof(socks_request_t)); + memset(conn->socks_request, 0, sizeof(socks_request_t)); + } conn->timestamp_created = now; conn->timestamp_lastread = now; @@ -115,6 +119,7 @@ void connection_free(connection_t *conn) { if (conn->identity_pkey) crypto_free_pk_env(conn->identity_pkey); tor_free(conn->nickname); + tor_free(conn->socks_request); if(conn->s >= 0) { log_fn(LOG_INFO,"closing fd %d.",conn->s); @@ -760,6 +765,9 @@ void assert_connection_ok(connection_t *conn, time_t now) assert_cpath_layer_ok(conn->cpath_layer); /* XXX unchecked, package window, deliver window. */ } + if (conn->type != CONN_TYPE_AP) { + assert(!conn->socks_request); + } switch(conn->type) { @@ -779,6 +787,12 @@ void assert_connection_ok(connection_t *conn, time_t now) case CONN_TYPE_AP: assert(conn->state >= _AP_CONN_STATE_MIN && conn->state <= _AP_CONN_STATE_MAX); + if (conn->state == AP_CONN_STATE_SOCKS_WAIT || + conn->state == AP_CONN_STATE_CIRCUIT_WAIT) { + assert(conn->socks_request); + } else { + assert(!conn->socks_request); + } break; case CONN_TYPE_DIR: assert(conn->state >= _DIR_CONN_STATE_MIN && |