mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-20 10:12:15 +01:00
r9855@Kushana: nickm | 2006-12-04 00:55:09 -0500
Merge circuit_about_to_close_connection and connection_about_to_close_connection. svn:r9021
This commit is contained in:
parent
f90cd5bfc0
commit
a91c12f2e7
@ -3,6 +3,11 @@ Changes in version 0.1.2.5-xxxx - 200?-??-??
|
||||
- Fix a bug when a PF socket is first used. (Patch from Fabian
|
||||
Keil)
|
||||
|
||||
o Controller bugfixes:
|
||||
- Report the circuit number correctly in STREAM CLOSED events. (Bug
|
||||
reported by Mike Perry)
|
||||
|
||||
|
||||
Changes in version 0.1.2.4-alpha - 2006-12-03
|
||||
o Major features:
|
||||
- Add support for using natd; this allows FreeBSDs earlier than
|
||||
|
@ -518,50 +518,6 @@ circuit_detach_stream(circuit_t *circ, edge_connection_t *conn)
|
||||
tor_assert(0); /* should never get here */
|
||||
}
|
||||
|
||||
/** Notify the global circuit list that <b>conn</b> is about to be
|
||||
* removed and then freed.
|
||||
*
|
||||
* If it's an OR conn, then mark-for-close all the circuits that use
|
||||
* that conn.
|
||||
*
|
||||
* If it's an edge conn, then detach it from its circ, so we don't
|
||||
* try to reference it later.
|
||||
*/
|
||||
void
|
||||
circuit_about_to_close_connection(connection_t *conn)
|
||||
{
|
||||
/* currently, we assume it's too late to flush conn's buf here.
|
||||
* down the road, maybe we'll consider that eof doesn't mean can't-write
|
||||
*/
|
||||
switch (conn->type) {
|
||||
case CONN_TYPE_OR: {
|
||||
if (!connection_state_is_open(conn)) {
|
||||
/* Inform any pending (not attached) circs that they should
|
||||
* give up. */
|
||||
circuit_n_conn_done(TO_OR_CONN(conn), 0);
|
||||
}
|
||||
/* Now close all the attached circuits on it. */
|
||||
circuit_unlink_all_from_or_conn(TO_OR_CONN(conn),
|
||||
END_CIRC_REASON_OR_CONN_CLOSED);
|
||||
return;
|
||||
}
|
||||
case CONN_TYPE_AP:
|
||||
case CONN_TYPE_EXIT: {
|
||||
circuit_t *circ;
|
||||
/* It's an edge conn. Need to remove it from the linked list of
|
||||
* conn's for this circuit. Confirm that 'end' relay command has
|
||||
* been sent. But don't kill the circuit.
|
||||
*/
|
||||
|
||||
circ = circuit_get_by_edge_conn(TO_EDGE_CONN(conn));
|
||||
if (!circ)
|
||||
return;
|
||||
|
||||
circuit_detach_stream(circ, TO_EDGE_CONN(conn));
|
||||
}
|
||||
} /* end switch */
|
||||
}
|
||||
|
||||
/** Find each circuit that has been unused for too long, or dirty
|
||||
* for too long and has no streax=ms on it: mark it for close.
|
||||
*/
|
||||
|
@ -393,6 +393,7 @@ connection_free_all(void)
|
||||
* - Exit conns need to call connection_dns_remove() if necessary.
|
||||
* - AP and Exit conns need to send an end cell if they can.
|
||||
* - DNS conns need to fail any resolves that are pending on them.
|
||||
* - OR and edge connections need to be unlinked from circuits.
|
||||
*/
|
||||
void
|
||||
connection_about_to_close_connection(connection_t *conn)
|
||||
@ -436,6 +437,9 @@ connection_about_to_close_connection(connection_t *conn)
|
||||
router_set_status(or_conn->identity_digest, 0);
|
||||
control_event_or_conn_status(or_conn, OR_CONN_EVENT_FAILED);
|
||||
}
|
||||
/* Inform any pending (not attached) circs that they should
|
||||
* give up. */
|
||||
circuit_n_conn_done(TO_OR_CONN(conn), 0);
|
||||
} else if (conn->hold_open_until_flushed) {
|
||||
/* XXXX009 We used to have an arg that told us whether we closed the
|
||||
* connection on purpose or not. Can we use hold_open_until_flushed
|
||||
@ -452,6 +456,9 @@ connection_about_to_close_connection(connection_t *conn)
|
||||
rep_hist_note_connection_died(or_conn->identity_digest, now);
|
||||
control_event_or_conn_status(or_conn, OR_CONN_EVENT_CLOSED);
|
||||
}
|
||||
/* Now close all the attached circuits on it. */
|
||||
circuit_unlink_all_from_or_conn(TO_OR_CONN(conn),
|
||||
END_CIRC_REASON_OR_CONN_CLOSED);
|
||||
break;
|
||||
case CONN_TYPE_AP:
|
||||
edge_conn = TO_EDGE_CONN(conn);
|
||||
@ -463,20 +470,23 @@ connection_about_to_close_connection(connection_t *conn)
|
||||
conn->marked_for_close_file, conn->marked_for_close);
|
||||
}
|
||||
if (!edge_conn->end_reason) {
|
||||
// XXXX Disable this before 0.1.2.x-final ships.
|
||||
// XXXX012 Disable this before 0.1.2.x-final ships.
|
||||
log_warn(LD_BUG,"Bug: Closing stream (marked at %s:%d) without having"
|
||||
" set end_reason. Please tell Nick.",
|
||||
conn->marked_for_close_file, conn->marked_for_close);
|
||||
}
|
||||
control_event_stream_status(edge_conn, STREAM_EVENT_CLOSED,
|
||||
edge_conn->end_reason);
|
||||
circ = circuit_get_by_edge_conn(edge_conn);
|
||||
if (circ)
|
||||
circuit_detach_stream(circ, edge_conn);
|
||||
break;
|
||||
case CONN_TYPE_EXIT:
|
||||
edge_conn = TO_EDGE_CONN(conn);
|
||||
circ = circuit_get_by_edge_conn(edge_conn);
|
||||
if (circ)
|
||||
circuit_detach_stream(circ, edge_conn);
|
||||
if (conn->state == EXIT_CONN_STATE_RESOLVING) {
|
||||
circ = circuit_get_by_edge_conn(edge_conn);
|
||||
if (circ)
|
||||
circuit_detach_stream(circ, edge_conn);
|
||||
connection_dns_remove(edge_conn);
|
||||
}
|
||||
break;
|
||||
|
@ -208,7 +208,6 @@ connection_remove(connection_t *conn)
|
||||
static void
|
||||
connection_unlink(connection_t *conn, int remove)
|
||||
{
|
||||
circuit_about_to_close_connection(conn);
|
||||
connection_about_to_close_connection(conn);
|
||||
if (remove) {
|
||||
connection_remove(conn);
|
||||
|
@ -673,7 +673,8 @@ typedef struct connection_t {
|
||||
* conn? */
|
||||
unsigned edge_has_sent_end:1; /**< For debugging; only used on edge
|
||||
* connections. Set once we've set the stream end,
|
||||
* and check in circuit_about_to_close_connection(). */
|
||||
* and check in connection_about_to_close_connection().
|
||||
*/
|
||||
/** Used for OR conns that shouldn't get any new circs attached to them. */
|
||||
unsigned int or_is_obsolete:1;
|
||||
/** For AP connections only. If 1, and we fail to reach the chosen exit,
|
||||
@ -1835,7 +1836,6 @@ int circuit_stream_is_being_handled(edge_connection_t *conn, uint16_t port,
|
||||
int min);
|
||||
void circuit_build_needed_circs(time_t now);
|
||||
void circuit_detach_stream(circuit_t *circ, edge_connection_t *conn);
|
||||
void circuit_about_to_close_connection(connection_t *conn);
|
||||
|
||||
void reset_bandwidth_test(void);
|
||||
int circuit_enough_testing_circs(void);
|
||||
|
Loading…
Reference in New Issue
Block a user