aboutsummaryrefslogtreecommitdiff
path: root/src/or/directory.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2004-05-05 01:26:57 +0000
committerNick Mathewson <nickm@torproject.org>2004-05-05 01:26:57 +0000
commit2ba0776b027db8fa619b61fb074bf2400ac18728 (patch)
tree2f217a760e380760ac2f6efd1f4b5a0c35327a92 /src/or/directory.c
parentd49d3dcc7bc19e9b9fb2aa29f7d94379a8aedf52 (diff)
downloadtor-2ba0776b027db8fa619b61fb074bf2400ac18728.tar
tor-2ba0776b027db8fa619b61fb074bf2400ac18728.tar.gz
Only connection_add connections once they have conn->s sett; refactor code around this. Should make stuff more bulletproof.
svn:r1788
Diffstat (limited to 'src/or/directory.c')
-rw-r--r--src/or/directory.c10
1 files changed, 2 insertions, 8 deletions
diff --git a/src/or/directory.c b/src/or/directory.c
index 9c6722390..e7f2608d3 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -50,11 +50,6 @@ void directory_initiate_command(routerinfo_t *router, int purpose,
conn->purpose = purpose;
- if(connection_add(conn) < 0) { /* no space, forget it */
- connection_free(conn);
- return;
- }
-
/* queue the command on the outbuf */
directory_send_command(conn, purpose, payload, payload_len);
@@ -67,13 +62,12 @@ void directory_initiate_command(routerinfo_t *router, int purpose,
switch(connection_connect(conn, conn->address, conn->addr, conn->port)) {
case -1:
router_mark_as_down(conn->nickname); /* don't try him again */
- connection_mark_for_close(conn, 0);
+ connection_free(conn);
return;
case 1:
conn->state = DIR_CONN_STATE_CLIENT_SENDING; /* start flushing conn */
/* fall through */
case 0:
- connection_set_poll_socket(conn);
connection_watch_events(conn, POLLIN | POLLOUT | POLLERR);
/* writable indicates finish, readable indicates broken link,
error indicates broken link in windowsland. */
@@ -91,7 +85,7 @@ void directory_initiate_command(routerinfo_t *router, int purpose,
}
conn->state = DIR_CONN_STATE_CLIENT_SENDING;
- connection_set_poll_socket(conn);
+ connection_add(conn);
connection_start_reading(conn);
}
}