summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2004-02-28 03:06:31 +0000
committerNick Mathewson <nickm@torproject.org>2004-02-28 03:06:31 +0000
commit88e222ff76e3643b20589dde8f0002ce8c559dc0 (patch)
treeac860237df65f045571f93d2c2810e08c0af13da
parentd0ad9b147ac4b0d3738d80b78b20070cc6aba592 (diff)
downloadtor-88e222ff76e3643b20589dde8f0002ce8c559dc0.tar.gz
tor-88e222ff76e3643b20589dde8f0002ce8c559dc0.zip
Make has_sent_end irrelevant: only try to send end if reason is nonzero
svn:r1148
-rw-r--r--src/or/circuit.c1
-rw-r--r--src/or/connection.c4
-rw-r--r--src/or/connection_edge.c14
3 files changed, 6 insertions, 13 deletions
diff --git a/src/or/circuit.c b/src/or/circuit.c
index ab83827f11..9ba946f300 100644
--- a/src/or/circuit.c
+++ b/src/or/circuit.c
@@ -1159,7 +1159,6 @@ int circuit_truncated(circuit_t *circ, crypt_path_t *layer) {
/* no need to send 'end' relay cells,
* because the other side's already dead
*/
- stream->has_sent_end = 1;
connection_mark_for_close(stream,0);
}
}
diff --git a/src/or/connection.c b/src/or/connection.c
index 43e8339ac2..7387afed3a 100644
--- a/src/or/connection.c
+++ b/src/or/connection.c
@@ -167,9 +167,7 @@ _connection_mark_for_close(connection_t *conn, char reason)
case CONN_TYPE_AP:
if (conn->state == EXIT_CONN_STATE_RESOLVING)
dns_cancel_pending_resolve(conn->address, conn);
- if (reason < _MIN_END_STREAM_REASON || reason > _MAX_END_STREAM_REASON)
- reason = END_STREAM_REASON_MISC;
- if (!conn->has_sent_end &&
+ if (!conn->has_sent_end && reason &&
connection_edge_end(conn, reason, conn->cpath_layer) < 0)
return -1;
break;
diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c
index a2189b70a4..9ab1b7c11c 100644
--- a/src/or/connection_edge.c
+++ b/src/or/connection_edge.c
@@ -147,7 +147,7 @@ int connection_edge_send_command(connection_t *fromconn, circuit_t *circ, int re
if(!circ) {
log_fn(LOG_WARN,"no circ. Closing.");
assert(fromconn);
- connection_mark_for_close(fromconn,0);
+ connection_mark_for_close(fromconn, 0);
return -1;
}
@@ -204,7 +204,6 @@ int connection_edge_process_relay_cell(cell_t *cell, circuit_t *circ, connection
if(rh.command == RELAY_COMMAND_END) {
log_fn(LOG_INFO,"Exit got end (%s) before we're connected. Marking for close.",
connection_edge_end_reason(cell->payload+RELAY_HEADER_SIZE, rh.length));
- conn->has_sent_end = 1; /* So we don't send an end cell. */
connection_mark_for_close(conn, 0);
return 0;
}
@@ -306,11 +305,9 @@ int connection_edge_process_relay_cell(cell_t *cell, circuit_t *circ, connection
conn->done_sending = 1;
shutdown(conn->s, 1); /* XXX check return; refactor NM */
if (conn->done_receiving) {
- conn->has_sent_end = 1; /* no need to send end, we just got one! */
- connection_mark_for_close(conn, END_STREAM_REASON_DONE);
+ connection_mark_for_close(conn, 0);
}
#else
- conn->has_sent_end = 1; /* no need to send end, we just got one! */
connection_mark_for_close(conn, 0);
#endif
return 0;
@@ -534,7 +531,7 @@ void connection_ap_expire_beginning(void) {
conn->timestamp_lastread += 15;
if(connection_ap_handshake_attach_circuit(conn)<0) {
/* it will never work */
- conn->has_sent_end = 1; /* Don't need to send end -- why? */
+ /* Don't need to send end -- why? */
/* XXX you're right, there's a bug. we should send an end cell
* above, right before circuit_detach_stream. But if attach_circuit()
* fails, then in fact we should mark without sending an end, because
@@ -561,8 +558,7 @@ void connection_ap_attach_pending(void)
continue;
if(connection_ap_handshake_attach_circuit(conn) < 0) {
/* it will never work */
- conn->has_sent_end = 1; /* because there is no 'other end' of the stream */
-/* (XXX maybe has_sent_end should be called no_need_to_send_end or something) */
+ /* Don't send end; there is no 'other end' of the stream */
connection_mark_for_close(conn,0);
}
}
@@ -728,7 +724,7 @@ static void connection_ap_handshake_send_begin(connection_t *ap_conn, circuit_t
ap_conn->stream_id = get_unique_stream_id_by_circ(circ);
if (ap_conn->stream_id==0) {
- ap_conn->has_sent_end = 1; /* there is no 'other side' yet */
+ /* Don't send end: there is no 'other side' yet */
connection_mark_for_close(ap_conn, 0);
return;
}