aboutsummaryrefslogtreecommitdiff
path: root/src/or/connection_or.c
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2005-12-28 07:19:55 +0000
committerRoger Dingledine <arma@torproject.org>2005-12-28 07:19:55 +0000
commit60cd03069a34f912878218d492591f342dd412cb (patch)
treee045efdf751304085558273f66e69d74a79c73a6 /src/or/connection_or.c
parentbbc4c8cef85dbf3c7e73e8dbefe590781ac03dca (diff)
downloadtor-60cd03069a34f912878218d492591f342dd412cb.tar
tor-60cd03069a34f912878218d492591f342dd412cb.tar.gz
when we connect to a helper node for the first time, close
that connection and its circuits. this lets us go back to using the old helper nodes rather than immediately using the last one in the list. svn:r5670
Diffstat (limited to 'src/or/connection_or.c')
-rw-r--r--src/or/connection_or.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/or/connection_or.c b/src/or/connection_or.c
index 863595b6f..d7dea9766 100644
--- a/src/or/connection_or.c
+++ b/src/or/connection_or.c
@@ -659,12 +659,13 @@ static int
connection_tls_finish_handshake(connection_t *conn)
{
char digest_rcvd[DIGEST_LEN];
+ int started_here = connection_or_nonopen_was_started_here(conn);
debug(LD_OR,"tls handshake done. verifying.");
if (connection_or_check_valid_handshake(conn, digest_rcvd) < 0)
return -1;
- if (!connection_or_nonopen_was_started_here(conn)) {
+ if (!started_here) {
#if 0
connection_t *c;
if ((c=connection_or_get_by_identity_digest(digest_rcvd))) {
@@ -683,18 +684,23 @@ connection_tls_finish_handshake(connection_t *conn)
directory_set_dirty();
conn->state = OR_CONN_STATE_OPEN;
+ control_event_or_conn_status(conn, OR_CONN_EVENT_CONNECTED);
+ if (started_here) {
+ rep_hist_note_connect_succeeded(conn->identity_digest, time(NULL));
+ if (helper_node_set_status(conn->identity_digest, 1) < 0) {
+ /* pending circs get closed in circuit_about_to_close_connection() */
+ return -1;
+ }
+ }
connection_watch_events(conn, EV_READ);
circuit_n_conn_done(conn, 1); /* send the pending creates, if any. */
- rep_hist_note_connect_succeeded(conn->identity_digest, time(NULL));
- helper_node_set_status(conn->identity_digest, 1);
- control_event_or_conn_status(conn, OR_CONN_EVENT_CONNECTED);
return 0;
}
/** Pack <b>cell</b> into wire-format, and write it onto <b>conn</b>'s
* outbuf.
*
- * (Commented out) If it's an OR conn, and an entire TLS record is
+ * If it's an OR conn, and an entire TLS record is
* ready, then try to flush the record now.
*/
void