diff options
author | Nick Mathewson <nickm@torproject.org> | 2004-05-12 19:17:09 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2004-05-12 19:17:09 +0000 |
commit | f1bc7af9f54bb4b563ffa024b1e32a6acacef26f (patch) | |
tree | 45bfe6288f7d804617795d79fd48049726e6dada /src/or/directory.c | |
parent | 4c9138d6406285077c3fc527f181610cd81b5727 (diff) | |
download | tor-f1bc7af9f54bb4b563ffa024b1e32a6acacef26f.tar.gz tor-f1bc7af9f54bb4b563ffa024b1e32a6acacef26f.zip |
Make "connected" a different case from "finished_flushing"; always close_immediate whhen connect() fails.
svn:r1852
Diffstat (limited to 'src/or/directory.c')
-rw-r--r-- | src/or/directory.c | 36 |
1 files changed, 16 insertions, 20 deletions
diff --git a/src/or/directory.c b/src/or/directory.c index 495f4822d6..4b529551bf 100644 --- a/src/or/directory.c +++ b/src/or/directory.c @@ -523,8 +523,8 @@ static int directory_handle_command(connection_t *conn) { } /** Write handler for directory connections; called when all data has - * been flushed. Handle a completed connection: close the connection - * or wait for a response as appropriate. + * been flushed. Close the connection or wait for a response as + * appropriate. */ int connection_dir_finished_flushing(connection_t *conn) { int e, len=sizeof(e); @@ -532,24 +532,6 @@ int connection_dir_finished_flushing(connection_t *conn) { tor_assert(conn && conn->type == CONN_TYPE_DIR); switch(conn->state) { - case DIR_CONN_STATE_CONNECTING: - if (getsockopt(conn->s, SOL_SOCKET, SO_ERROR, (void*)&e, &len) < 0) { /* not yet */ - if(!ERRNO_IS_CONN_EINPROGRESS(tor_socket_errno(conn->s))) { - log_fn(LOG_DEBUG,"in-progress connect failed. Removing."); - router_mark_as_down(conn->nickname); /* don't try him again */ - connection_mark_for_close(conn,0); - return -1; - } else { - return 0; /* no change, see if next time is better */ - } - } - /* the connect has finished. */ - - log_fn(LOG_INFO,"Dir connection to router %s:%u established.", - conn->address,conn->port); - - conn->state = DIR_CONN_STATE_CLIENT_SENDING; /* start flushing conn */ - return 0; case DIR_CONN_STATE_CLIENT_SENDING: log_fn(LOG_DEBUG,"client finished sending command."); conn->state = DIR_CONN_STATE_CLIENT_READING; @@ -566,6 +548,20 @@ int connection_dir_finished_flushing(connection_t *conn) { return 0; } +/** Connected handler for directory connections: begin sending data to the + * server */ +int connection_dir_finished_connecting(connection_t *conn) +{ + tor_assert(conn && conn->type == CONN_TYPE_DIR); + tor_assert(conn->state == DIR_CONN_STATE_CONNECTING); + + log_fn(LOG_INFO,"Dir connection to router %s:%u established.", + conn->address,conn->port); + + conn->state = DIR_CONN_STATE_CLIENT_SENDING; /* start flushing conn */ + return 0; +} + /* Local Variables: mode:c |