summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2007-02-07 06:54:27 +0000
committerNick Mathewson <nickm@torproject.org>2007-02-07 06:54:27 +0000
commit071738c2d5ef08131633631648c8952840e7c1eb (patch)
tree3b3c141af42e5ce09ee41d56e96077887a52396c /src
parent026c11c42e30258d273f6ecc41ae1634981b84b3 (diff)
downloadtor-071738c2d5ef08131633631648c8952840e7c1eb.tar.gz
tor-071738c2d5ef08131633631648c8952840e7c1eb.zip
r11673@catbus: nickm | 2007-02-06 14:40:07 -0500
Report stream end events where a resolve succeeded or where we got a socks protocol error correctly, rather than calling both of them "INTERNAL". Turn ALREADY_SOCKS_REPLIED into a flag rather than a reason. This will help debug 367 part 2 a little. svn:r9511
Diffstat (limited to 'src')
-rw-r--r--src/or/connection_edge.c17
-rw-r--r--src/or/control.c1
-rw-r--r--src/or/or.h7
-rw-r--r--src/or/relay.c7
4 files changed, 19 insertions, 13 deletions
diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c
index 4d329e2e3f..53639dfdf9 100644
--- a/src/or/connection_edge.c
+++ b/src/or/connection_edge.c
@@ -50,7 +50,7 @@ _connection_mark_unattached_ap(edge_connection_t *conn, int endreason,
}
if (!conn->socks_request->has_finished) {
- if (endreason == END_STREAM_REASON_ALREADY_SOCKS_REPLIED)
+ if (endreason & END_STREAM_REASON_FLAG_ALREADY_SOCKS_REPLIED)
log_warn(LD_BUG,
"Bug: stream (marked at %s:%d) sending two socks replies?",
file, line);
@@ -1216,7 +1216,8 @@ connection_ap_handshake_rewrite_and_attach(edge_connection_t *conn,
strlen(socks->address),
socks->address, -1);
connection_mark_unattached_ap(conn,
- END_STREAM_REASON_ALREADY_SOCKS_REPLIED);
+ END_STREAM_REASON_DONE |
+ END_STREAM_REASON_FLAG_ALREADY_SOCKS_REPLIED);
return 0;
}
} else {
@@ -1307,7 +1308,8 @@ connection_ap_handshake_rewrite_and_attach(edge_connection_t *conn,
connection_ap_handshake_socks_resolved(conn,RESOLVED_TYPE_ERROR,
0,NULL,-1);
connection_mark_unattached_ap(conn,
- END_STREAM_REASON_ALREADY_SOCKS_REPLIED);
+ END_STREAM_REASON_SOCKSPROTOCOL |
+ END_STREAM_REASON_FLAG_ALREADY_SOCKS_REPLIED);
return -1;
}
if (tor_inet_aton(socks->address, &in)) { /* see if it's an IP already */
@@ -1315,7 +1317,8 @@ connection_ap_handshake_rewrite_and_attach(edge_connection_t *conn,
connection_ap_handshake_socks_resolved(conn,RESOLVED_TYPE_IPV4,4,
(char*)&answer,-1);
connection_mark_unattached_ap(conn,
- END_STREAM_REASON_ALREADY_SOCKS_REPLIED);
+ END_STREAM_REASON_DONE |
+ END_STREAM_REASON_FLAG_ALREADY_SOCKS_REPLIED);
return 0;
}
rep_hist_note_used_resolve(time(NULL)); /* help predict this next time */
@@ -1373,7 +1376,8 @@ connection_ap_handshake_rewrite_and_attach(edge_connection_t *conn,
connection_ap_handshake_socks_resolved(conn,RESOLVED_TYPE_ERROR,
0,NULL,-1);
connection_mark_unattached_ap(conn,
- END_STREAM_REASON_ALREADY_SOCKS_REPLIED);
+ END_STREAM_REASON_SOCKSPROTOCOL |
+ END_STREAM_REASON_FLAG_ALREADY_SOCKS_REPLIED);
return -1;
}
@@ -1574,7 +1578,8 @@ connection_ap_handshake_process_socks(edge_connection_t *conn)
END_STREAM_REASON_SOCKSPROTOCOL);
}
connection_mark_unattached_ap(conn,
- END_STREAM_REASON_ALREADY_SOCKS_REPLIED);
+ END_STREAM_REASON_SOCKSPROTOCOL |
+ END_STREAM_REASON_FLAG_ALREADY_SOCKS_REPLIED);
return -1;
} /* else socks handshake is done, continue processing */
diff --git a/src/or/control.c b/src/or/control.c
index 402ca267d8..a374944ec3 100644
--- a/src/or/control.c
+++ b/src/or/control.c
@@ -3156,7 +3156,6 @@ stream_end_reason_to_string(int reason)
case END_STREAM_REASON_TORPROTOCOL: return "TORPROTOCOL";
case END_STREAM_REASON_NOTDIRECTORY: return "NOTDIRECTORY";
- case END_STREAM_REASON_ALREADY_SOCKS_REPLIED: return "INTERNAL";
case END_STREAM_REASON_CANT_ATTACH: return "CANT_ATTACH";
case END_STREAM_REASON_NET_UNREACHABLE: return "NET_UNREACHABLE";
case END_STREAM_REASON_SOCKSPROTOCOL: return "SOCKS_PROTOCOL";
diff --git a/src/or/or.h b/src/or/or.h
index e0c680983d..ad1138b706 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -518,8 +518,7 @@ typedef enum {
* and are not intended to be put in relay end cells. They are here
* to be more informative when sending back socks replies to the
* application. */
-/** DOCDOC */
-#define END_STREAM_REASON_ALREADY_SOCKS_REPLIED 256
+/* XXXX 256 is no longer used; feel free to reuse it. */
/** DOCDOC */
#define END_STREAM_REASON_CANT_ATTACH 257
/** DOCDOC */
@@ -540,6 +539,10 @@ typedef enum {
/** Bitwise-or this with the argument to control_event_stream_status
* to indicate that we already sent a CLOSED stream event. */
#define END_STREAM_REASON_FLAG_ALREADY_SENT_CLOSED 1024
+/** Bitwise-or this with endreason to indicate that we already sent
+ * a socks reply, and no further reply needs to be sent from
+ * connection_mark_unattached_ap(). */
+#define END_STREAM_REASON_FLAG_ALREADY_SOCKS_REPLIED 2048
/* DOCDOC */
#define RESOLVED_TYPE_HOSTNAME 0
diff --git a/src/or/relay.c b/src/or/relay.c
index 559d1f6433..018d16e293 100644
--- a/src/or/relay.c
+++ b/src/or/relay.c
@@ -584,7 +584,7 @@ connection_edge_end_reason_str(int reason)
socks5_reply_status_t
connection_edge_end_reason_socks5_response(int reason)
{
- switch (reason) {
+ switch (reason & END_STREAM_REASON_MASK) {
case 0:
return SOCKS5_SUCCEEDED;
case END_STREAM_REASON_MISC:
@@ -612,8 +612,6 @@ connection_edge_end_reason_socks5_response(int reason)
case END_STREAM_REASON_TORPROTOCOL:
return SOCKS5_GENERAL_ERROR;
- case END_STREAM_REASON_ALREADY_SOCKS_REPLIED:
- return SOCKS5_SUCCEEDED; /* never used */
case END_STREAM_REASON_CANT_ATTACH:
return SOCKS5_GENERAL_ERROR;
case END_STREAM_REASON_NET_UNREACHABLE:
@@ -922,7 +920,8 @@ connection_edge_process_relay_cell_not_open(
cell->payload+RELAY_HEADER_SIZE+2, /*answer*/
ttl);
connection_mark_unattached_ap(conn,
- END_STREAM_REASON_ALREADY_SOCKS_REPLIED);
+ END_STREAM_REASON_DONE |
+ END_STREAM_REASON_FLAG_ALREADY_SOCKS_REPLIED);
return 0;
}