circ->timestamp_created = time(NULL);
- circ->marked_for_close = 0;
-
circ->p_circ_id = p_circ_id;
circ->p_conn = p_conn;
}
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;
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;
}
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);
}
}
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);
}
}
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;
}
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)",
/* 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.");