summaryrefslogtreecommitdiff
path: root/src/or/connection_edge.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2005-03-01 22:42:31 +0000
committerNick Mathewson <nickm@torproject.org>2005-03-01 22:42:31 +0000
commitafe414f070cee8ce1469fc6db8f51bb9e71c654d (patch)
tree75bf4f5349f0bfd7bab12433b200329f45e91e3a /src/or/connection_edge.c
parent4ddf768a4fc98bfc2e18a7076bd0397967e3de5e (diff)
downloadtor-afe414f070cee8ce1469fc6db8f51bb9e71c654d.tar.gz
tor-afe414f070cee8ce1469fc6db8f51bb9e71c654d.zip
Revise all calls to connection_edge_end to avoid sending MISC, and to take errno into account where possible.
svn:r3720
Diffstat (limited to 'src/or/connection_edge.c')
-rw-r--r--src/or/connection_edge.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c
index 937b282e10..c30fd5285c 100644
--- a/src/or/connection_edge.c
+++ b/src/or/connection_edge.c
@@ -78,6 +78,7 @@ int connection_edge_process_inbuf(connection_t *conn, int package_partial) {
case AP_CONN_STATE_OPEN:
case EXIT_CONN_STATE_OPEN:
if (connection_edge_package_raw_inbuf(conn, package_partial) < 0) {
+ /* XXXX We can't tell *why* package failed. -NM */
connection_edge_end(conn, END_STREAM_REASON_MISC, conn->cpath_layer);
connection_mark_for_close(conn);
return -1;
@@ -96,7 +97,7 @@ int connection_edge_process_inbuf(connection_t *conn, int package_partial) {
#ifdef TOR_FRAGILE
tor_assert(0);
#endif
- connection_edge_end(conn, END_STREAM_REASON_MISC, conn->cpath_layer);
+ connection_edge_end(conn, END_STREAM_REASON_INTERNAL, conn->cpath_layer);
connection_mark_for_close(conn);
return -1;
}
@@ -161,6 +162,17 @@ connection_edge_end(connection_t *conn, char reason, crypt_path_t *cpath_layer)
return 0;
}
+/** DOCDOC **/
+int
+connection_edge_end_errno(connection_t *conn, crypt_path_t *cpath_layer)
+{
+ uint8_t reason;
+ tor_assert(conn);
+ reason = (uint8_t)errno_to_end_reason(tor_socket_errno(conn->s));
+ return connection_edge_end(conn, reason, cpath_layer);
+}
+
+
/** Connection <b>conn</b> has finished writing and has no bytes left on
* its outbuf.
*
@@ -1036,7 +1048,7 @@ int connection_exit_begin_conn(cell_t *cell, circuit_t *circ) {
/* default to failed, change in dns_resolve if it turns out not to fail */
if (we_are_hibernating()) {
- connection_edge_end(n_stream, END_STREAM_REASON_EXITPOLICY, n_stream->cpath_layer);
+ connection_edge_end(n_stream, END_STREAM_REASON_HIBERNATING, n_stream->cpath_layer);
connection_free(n_stream);
return 0;
}
@@ -1156,8 +1168,7 @@ connection_exit_connect(connection_t *conn) {
log_fn(LOG_DEBUG,"about to try connecting");
switch (connection_connect(conn, conn->address, addr, port)) {
case -1:
- connection_edge_end(conn, END_STREAM_REASON_CONNECTREFUSED,
- conn->cpath_layer);
+ connection_edge_end_errno(conn, conn->cpath_layer);
circuit_detach_stream(circuit_get_by_conn(conn), conn);
connection_free(conn);
return;