summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2004-03-03 04:54:16 +0000
committerRoger Dingledine <arma@torproject.org>2004-03-03 04:54:16 +0000
commit8275e2302ca3995f15a0b78e7a5341230653694c (patch)
treee6d2847d922f9d73f6f7b857b1a20aa621363902
parent77bb3e054e76e9641b750db6cd6826e1c6096a9e (diff)
downloadtor-8275e2302ca3995f15a0b78e7a5341230653694c.tar.gz
tor-8275e2302ca3995f15a0b78e7a5341230653694c.zip
make socks5 not give a spurious warning
also rename AP_CONN_STATE_CONNECTING to _CONNECT_WAIT svn:r1208
-rw-r--r--src/or/connection_edge.c14
-rw-r--r--src/or/main.c1
-rw-r--r--src/or/or.h2
3 files changed, 9 insertions, 8 deletions
diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c
index 7207800ed5..ced8baacbf 100644
--- a/src/or/connection_edge.c
+++ b/src/or/connection_edge.c
@@ -220,7 +220,7 @@ int connection_edge_process_relay_cell(cell_t *cell, circuit_t *circ, connection
return 0;
}
if(conn->type == CONN_TYPE_AP && rh.command == RELAY_COMMAND_CONNECTED) {
- if(conn->state != AP_CONN_STATE_CONNECTING) {
+ if(conn->state != AP_CONN_STATE_CONNECT_WAIT) {
log_fn(LOG_WARN,"Got 'connected' while not in state connecting. Dropping.");
return 0;
}
@@ -445,6 +445,7 @@ int connection_edge_finished_flushing(connection_t *conn) {
return 0;
case AP_CONN_STATE_SOCKS_WAIT:
case AP_CONN_STATE_CIRCUIT_WAIT:
+ case AP_CONN_STATE_CONNECT_WAIT:
connection_stop_writing(conn);
return 0;
default:
@@ -539,7 +540,7 @@ void connection_ap_expire_beginning(void) {
for (i = 0; i < n; ++i) {
conn = carray[i];
if (conn->type != CONN_TYPE_AP ||
- conn->state != AP_CONN_STATE_CONNECTING)
+ conn->state != AP_CONN_STATE_CONNECT_WAIT)
continue;
if (now - conn->timestamp_lastread >= 15) {
log_fn(LOG_WARN,"Stream is %d seconds late. Retrying.",
@@ -770,7 +771,7 @@ static void connection_ap_handshake_send_begin(connection_t *ap_conn, circuit_t
ap_conn->package_window = STREAMWINDOW_START;
ap_conn->deliver_window = STREAMWINDOW_START;
- ap_conn->state = AP_CONN_STATE_CONNECTING;
+ ap_conn->state = AP_CONN_STATE_CONNECT_WAIT;
/* XXX Right now, we rely on the socks client not to send us any data
* XXX until we've sent back a socks reply. (If it does, we could wind
* XXX up packaging that data and sending it to the exit, then later having
@@ -786,7 +787,7 @@ static int connection_ap_handshake_socks_reply(connection_t *conn, char *reply,
if(replylen) { /* we already have a reply in mind */
connection_write_to_buf(reply, replylen, conn);
- return flush_buf(conn->s, conn->outbuf, &conn->outbuf_flushlen); /* try to flush it */
+ return 0;
}
assert(conn->socks_request);
if(conn->socks_request->socks_version == 4) {
@@ -796,7 +797,6 @@ static int connection_ap_handshake_socks_reply(connection_t *conn, char *reply,
buf[1] = (success ? SOCKS4_GRANTED : SOCKS4_REJECT);
/* leave version, destport, destip zero */
connection_write_to_buf(buf, SOCKS4_NETWORK_LEN, conn);
- return flush_buf(conn->s, conn->outbuf, &conn->outbuf_flushlen); /* try to flush it */
}
if(conn->socks_request->socks_version == 5) {
buf[0] = 5; /* version 5 */
@@ -808,9 +808,9 @@ static int connection_ap_handshake_socks_reply(connection_t *conn, char *reply,
memset(buf+4,0,6); /* Set external addr/port to 0.
The spec doesn't seem to say what to do here. -RD */
connection_write_to_buf(buf,10,conn);
- return flush_buf(conn->s, conn->outbuf, &conn->outbuf_flushlen); /* try to flush it */
}
- return 0; /* if socks_version isn't 4 or 5, don't send anything */
+ /* if socks_version isn't 4 or 5, don't send anything */
+ return 0;
}
static int connection_exit_begin_conn(cell_t *cell, circuit_t *circ) {
diff --git a/src/or/main.c b/src/or/main.c
index c9b02d3be5..d9eeff2864 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -216,6 +216,7 @@ static void conn_write(int i) {
/* this connection is broken. remove it. */
log_fn(LOG_WARN,"Unhandled error on read for %s connection (fd %d); removing",
conn_type_to_string[conn->type], conn->s);
+ conn->has_sent_end = 1; /* otherwise we cry wolf about duplicate close */
connection_mark_for_close(conn,0);
}
}
diff --git a/src/or/or.h b/src/or/or.h
index 51a38032dd..17ed66967e 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -159,7 +159,7 @@
#define _AP_CONN_STATE_MIN 5
#define AP_CONN_STATE_SOCKS_WAIT 5
#define AP_CONN_STATE_CIRCUIT_WAIT 6
-#define AP_CONN_STATE_CONNECTING 7
+#define AP_CONN_STATE_CONNECT_WAIT 7
#define AP_CONN_STATE_OPEN 8
#define _AP_CONN_STATE_MAX 8