mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-28 06:13:31 +01:00
Clarify comment. Use CONN_IS_EDGE more. Try to be more zealous about calling connection_edge_end when things go bad with edge conns in connection.c
svn:r3671
This commit is contained in:
parent
5dd58e27d9
commit
22c38b0f9b
@ -220,7 +220,7 @@ void connection_about_to_close_connection(connection_t *conn)
|
||||
|
||||
assert(conn->marked_for_close);
|
||||
|
||||
if (conn->type == CONN_TYPE_AP || conn->type == CONN_TYPE_EXIT) {
|
||||
if (CONN_IS_EDGE(conn)) {
|
||||
if (!conn->has_sent_end) {
|
||||
log_fn(LOG_WARN,"Harmless bug: Edge connection hasn't sent end yet?");
|
||||
#ifdef TOR_FRAGILE
|
||||
@ -903,10 +903,10 @@ loop_again:
|
||||
if (connection_read_to_buf(conn, &max_to_read) < 0) {
|
||||
/* There's a read error; kill the connection.*/
|
||||
connection_close_immediate(conn); /* Don't flush; connection is dead. */
|
||||
if (conn->type == CONN_TYPE_AP || conn->type == CONN_TYPE_EXIT) {
|
||||
if (CONN_IS_EDGE(conn)) {
|
||||
connection_edge_end(conn, (char)(connection_state_is_open(conn) ?
|
||||
END_STREAM_REASON_MISC : END_STREAM_REASON_CONNECTFAILED),
|
||||
conn->cpath_layer);
|
||||
END_STREAM_REASON_MISC : END_STREAM_REASON_CONNECTFAILED),
|
||||
conn->cpath_layer);
|
||||
}
|
||||
connection_mark_for_close(conn);
|
||||
return -1;
|
||||
@ -1073,7 +1073,8 @@ int connection_handle_write(connection_t *conn) {
|
||||
if (connection_state_is_connecting(conn)) {
|
||||
if (getsockopt(conn->s, SOL_SOCKET, SO_ERROR, (void*)&e, &len) < 0) {
|
||||
log_fn(LOG_WARN,"getsockopt() syscall failed?! Please report to tor-ops.");
|
||||
connection_close_immediate(conn);
|
||||
if (CONN_IS_EDGE(conn))
|
||||
connection_edge_end(conn, END_STREAM_REASON_MISC, conn->cpath_layer);
|
||||
connection_mark_for_close(conn);
|
||||
return -1;
|
||||
}
|
||||
@ -1081,6 +1082,10 @@ int connection_handle_write(connection_t *conn) {
|
||||
/* some sort of error, but maybe just inprogress still */
|
||||
if (!ERRNO_IS_CONN_EINPROGRESS(e)) {
|
||||
log_fn(LOG_INFO,"in-progress connect failed. Removing.");
|
||||
if (CONN_IS_EDGE(conn))
|
||||
connection_edge_end(conn, END_STREAM_REASON_CONNECTFAILED,
|
||||
conn->cpath_layer);
|
||||
|
||||
connection_close_immediate(conn);
|
||||
connection_mark_for_close(conn);
|
||||
/* it's safe to pass OPs to router_mark_as_down(), since it just
|
||||
@ -1143,6 +1148,11 @@ int connection_handle_write(connection_t *conn) {
|
||||
} else {
|
||||
result = flush_buf(conn->s, conn->outbuf, &conn->outbuf_flushlen);
|
||||
if (result < 0) {
|
||||
/* XXXX Is this right? -NM
|
||||
if (CONN_IS_EDGE(conn))
|
||||
connection_edge_end(conn, END_STREAM_REASON_MISC,
|
||||
conn->cpath_layer);
|
||||
*/
|
||||
connection_close_immediate(conn); /* Don't flush; connection is dead. */
|
||||
conn->has_sent_end = 1;
|
||||
connection_mark_for_close(conn);
|
||||
@ -1177,7 +1187,7 @@ void connection_write_to_buf(const char *string, size_t len, connection_t *conn)
|
||||
return;
|
||||
|
||||
if (write_to_buf(string, len, conn->outbuf) < 0) {
|
||||
if (conn->type == CONN_TYPE_AP || conn->type == CONN_TYPE_EXIT) {
|
||||
if (CONN_IS_EDGE(conn)) {
|
||||
/* if it failed, it means we have our package/delivery windows set
|
||||
wrong compared to our max outbuf size. close the whole circuit. */
|
||||
log_fn(LOG_WARN,"write_to_buf failed. Closing circuit (fd %d).", conn->s);
|
||||
@ -1566,7 +1576,7 @@ void assert_connection_ok(connection_t *conn, time_t now)
|
||||
tor_assert(conn->tls);
|
||||
}
|
||||
|
||||
if (conn->type != CONN_TYPE_EXIT && conn->type != CONN_TYPE_AP) {
|
||||
if (CONN_IS_EDGE(conn)) {
|
||||
tor_assert(!conn->stream_id);
|
||||
tor_assert(!conn->next_stream);
|
||||
tor_assert(!conn->cpath_layer);
|
||||
|
@ -64,7 +64,7 @@ int connection_edge_reached_eof(connection_t *conn) {
|
||||
int connection_edge_process_inbuf(connection_t *conn, int package_partial) {
|
||||
|
||||
tor_assert(conn);
|
||||
tor_assert(conn->type == CONN_TYPE_AP || conn->type == CONN_TYPE_EXIT);
|
||||
tor_assert(CONN_IS_EDGE(conn));
|
||||
|
||||
switch (conn->state) {
|
||||
case AP_CONN_STATE_SOCKS_WAIT:
|
||||
@ -105,7 +105,7 @@ int connection_edge_process_inbuf(connection_t *conn, int package_partial) {
|
||||
* Mark it for close and return 0.
|
||||
*/
|
||||
int connection_edge_destroy(uint16_t circ_id, connection_t *conn) {
|
||||
tor_assert(conn->type == CONN_TYPE_AP || conn->type == CONN_TYPE_EXIT);
|
||||
tor_assert(CONN_IS_EDGE(conn));
|
||||
|
||||
if (conn->marked_for_close)
|
||||
return 0; /* already marked; probably got an 'end' */
|
||||
@ -173,7 +173,7 @@ connection_edge_end(connection_t *conn, char reason, crypt_path_t *cpath_layer)
|
||||
*/
|
||||
int connection_edge_finished_flushing(connection_t *conn) {
|
||||
tor_assert(conn);
|
||||
tor_assert(conn->type == CONN_TYPE_AP || conn->type == CONN_TYPE_EXIT);
|
||||
tor_assert(CONN_IS_EDGE(conn));
|
||||
|
||||
switch (conn->state) {
|
||||
case AP_CONN_STATE_OPEN:
|
||||
@ -1148,8 +1148,8 @@ connection_exit_connect(connection_t *conn) {
|
||||
conn->state = EXIT_CONN_STATE_CONNECTING;
|
||||
|
||||
connection_watch_events(conn, EV_WRITE | EV_READ);
|
||||
/* writable indicates finish, readable indicates broken link,
|
||||
error indicates broken link in windowsland. */
|
||||
/* writable indicates finish;
|
||||
* readable/error indicates broken link in windowsland. */
|
||||
return;
|
||||
/* case 1: fall through */
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user