[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] Clarify comment. Use CONN_IS_EDGE more. Try to be more zeal...
- To: or-cvs@xxxxxxxxxxxxx
- Subject: [or-cvs] Clarify comment. Use CONN_IS_EDGE more. Try to be more zeal...
- From: nickm@xxxxxxxx (Nick Mathewson)
- Date: Wed, 23 Feb 2005 15:35:29 -0500 (EST)
- Delivered-to: archiver@seul.org
- Delivered-to: or-cvs-outgoing@seul.org
- Delivered-to: or-cvs@seul.org
- Delivery-date: Wed, 23 Feb 2005 15:35:51 -0500
- Reply-to: or-dev@xxxxxxxxxxxxx
- Sender: owner-or-cvs@xxxxxxxxxxxxx
Update of /home/or/cvsroot/tor/src/or
In directory moria.mit.edu:/tmp/cvs-serv19010/src/or
Modified Files:
connection.c connection_edge.c
Log Message:
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
Index: connection.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/connection.c,v
retrieving revision 1.328
retrieving revision 1.329
diff -u -d -r1.328 -r1.329
--- connection.c 22 Feb 2005 08:18:35 -0000 1.328
+++ connection.c 23 Feb 2005 20:35:26 -0000 1.329
@@ -220,7 +220,7 @@
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 @@
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 @@
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 @@
/* 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 @@
} 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 @@
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 @@
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);
Index: connection_edge.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/connection_edge.c,v
retrieving revision 1.283
retrieving revision 1.284
diff -u -d -r1.283 -r1.284
--- connection_edge.c 23 Feb 2005 06:46:54 -0000 1.283
+++ connection_edge.c 23 Feb 2005 20:35:26 -0000 1.284
@@ -64,7 +64,7 @@
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 @@
* 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 @@
*/
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 @@
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 */
}