patches/answers to nick's commit

svn:r1146
This commit is contained in:
Roger Dingledine 2004-02-27 23:23:33 +00:00
parent c5bbb571d2
commit 611f117ce1
4 changed files with 13 additions and 9 deletions

View file

@ -64,8 +64,6 @@ circuit_t *circuit_new(uint16_t p_circ_id, connection_t *p_conn) {
circ->timestamp_created = time(NULL);
circ->marked_for_close = 0;
circ->p_circ_id = p_circ_id;
circ->p_conn = p_conn;

View file

@ -350,10 +350,11 @@ int connection_connect(connection_t *conn, char *address, uint32_t addr, uint16_
}
static void listener_close_if_present(int type) {
connection_t *conn;
assert(type == CONN_TYPE_OR_LISTENER ||
type == CONN_TYPE_AP_LISTENER ||
type == CONN_TYPE_DIR_LISTENER);
connection_t *conn = connection_get_by_type(type);
conn = connection_get_by_type(type);
if (conn) {
close(conn->s);
conn->s = -1;
@ -736,10 +737,6 @@ int connection_send_destroy(uint16_t circ_id, connection_t *conn) {
if(!connection_speaks_cells(conn)) {
log_fn(LOG_INFO,"CircID %d: At an edge. Marking connection for close.",
circ_id);
if(conn->type == CONN_TYPE_EXIT && conn->state == EXIT_CONN_STATE_RESOLVING) {
log_fn(LOG_INFO,"...and informing resolver we don't want the answer anymore.");
dns_cancel_pending_resolve(conn->address, conn);
}
connection_mark_for_close(conn, END_STREAM_REASON_DESTROY);
return 0;
}

View file

@ -535,6 +535,10 @@ void connection_ap_expire_beginning(void) {
if(connection_ap_handshake_attach_circuit(conn)<0) {
/* it will never work */
conn->has_sent_end = 1; /* 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
* we're not connected to anything. -RD */
connection_mark_for_close(conn, 0);
}
}
@ -557,7 +561,8 @@ void connection_ap_attach_pending(void)
continue;
if(connection_ap_handshake_attach_circuit(conn) < 0) {
/* it will never work */
conn->has_sent_end = 1; /* why? */
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) */
connection_mark_for_close(conn,0);
}
}
@ -723,6 +728,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 */
connection_mark_for_close(ap_conn, 0);
return;
}

View file

@ -273,6 +273,9 @@ static void run_connection_housekeeping(int i, time_t now) {
log_fn(LOG_INFO,"Expiring connection to %d (%s:%d).",
i,conn->address, conn->port);
connection_mark_for_close(conn,0); /* Suppress end ??? */
/* XXX there's no concept of 'suppressing end' here, because it's an OR
* connection, and there's no such thing as an end cell for an OR
* connection. -RD */
} else {
/* either a full router, or we've got a circuit. send a padding cell. */
log_fn(LOG_DEBUG,"Sending keepalive to (%s:%d)",
@ -543,7 +546,7 @@ static int do_main_loop(void) {
/* let catch() handle things like ^c, and otherwise don't worry about it */
if(poll_result < 0) {
if(errno != EINTR) { /* let the program survive things like ^z */
log_fn(LOG_ERR,"poll failed.");
log_fn(LOG_ERR,"poll failed: %s",strerror(errno));
return -1;
} else {
log_fn(LOG_DEBUG,"poll interrupted.");