Make has_sent_end irrelevant: only try to send end if reason is nonzero

svn:r1148
This commit is contained in:
Nick Mathewson 2004-02-28 03:06:31 +00:00
parent d0ad9b147a
commit 88e222ff76
3 changed files with 6 additions and 13 deletions

View File

@ -1159,7 +1159,6 @@ int circuit_truncated(circuit_t *circ, crypt_path_t *layer) {
/* no need to send 'end' relay cells, /* no need to send 'end' relay cells,
* because the other side's already dead * because the other side's already dead
*/ */
stream->has_sent_end = 1;
connection_mark_for_close(stream,0); connection_mark_for_close(stream,0);
} }
} }

View File

@ -167,9 +167,7 @@ _connection_mark_for_close(connection_t *conn, char reason)
case CONN_TYPE_AP: case CONN_TYPE_AP:
if (conn->state == EXIT_CONN_STATE_RESOLVING) if (conn->state == EXIT_CONN_STATE_RESOLVING)
dns_cancel_pending_resolve(conn->address, conn); dns_cancel_pending_resolve(conn->address, conn);
if (reason < _MIN_END_STREAM_REASON || reason > _MAX_END_STREAM_REASON) if (!conn->has_sent_end && reason &&
reason = END_STREAM_REASON_MISC;
if (!conn->has_sent_end &&
connection_edge_end(conn, reason, conn->cpath_layer) < 0) connection_edge_end(conn, reason, conn->cpath_layer) < 0)
return -1; return -1;
break; break;

View File

@ -204,7 +204,6 @@ int connection_edge_process_relay_cell(cell_t *cell, circuit_t *circ, connection
if(rh.command == RELAY_COMMAND_END) { if(rh.command == RELAY_COMMAND_END) {
log_fn(LOG_INFO,"Exit got end (%s) before we're connected. Marking for close.", 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)); 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); connection_mark_for_close(conn, 0);
return 0; return 0;
} }
@ -306,11 +305,9 @@ int connection_edge_process_relay_cell(cell_t *cell, circuit_t *circ, connection
conn->done_sending = 1; conn->done_sending = 1;
shutdown(conn->s, 1); /* XXX check return; refactor NM */ shutdown(conn->s, 1); /* XXX check return; refactor NM */
if (conn->done_receiving) { if (conn->done_receiving) {
conn->has_sent_end = 1; /* no need to send end, we just got one! */ connection_mark_for_close(conn, 0);
connection_mark_for_close(conn, END_STREAM_REASON_DONE);
} }
#else #else
conn->has_sent_end = 1; /* no need to send end, we just got one! */
connection_mark_for_close(conn, 0); connection_mark_for_close(conn, 0);
#endif #endif
return 0; return 0;
@ -534,7 +531,7 @@ void connection_ap_expire_beginning(void) {
conn->timestamp_lastread += 15; conn->timestamp_lastread += 15;
if(connection_ap_handshake_attach_circuit(conn)<0) { if(connection_ap_handshake_attach_circuit(conn)<0) {
/* it will never work */ /* 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 /* XXX you're right, there's a bug. we should send an end cell
* above, right before circuit_detach_stream. But if attach_circuit() * above, right before circuit_detach_stream. But if attach_circuit()
* fails, then in fact we should mark without sending an end, because * fails, then in fact we should mark without sending an end, because
@ -561,8 +558,7 @@ void connection_ap_attach_pending(void)
continue; continue;
if(connection_ap_handshake_attach_circuit(conn) < 0) { if(connection_ap_handshake_attach_circuit(conn) < 0) {
/* it will never work */ /* it will never work */
conn->has_sent_end = 1; /* because there is no 'other end' of the stream */ /* Don't send end; there is no 'other end' of the stream */
/* (XXX maybe has_sent_end should be called no_need_to_send_end or something) */
connection_mark_for_close(conn,0); 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); ap_conn->stream_id = get_unique_stream_id_by_circ(circ);
if (ap_conn->stream_id==0) { 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); connection_mark_for_close(ap_conn, 0);
return; return;
} }