aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--changes/bug178765
-rw-r--r--src/or/connection.c7
-rw-r--r--src/or/connection_edge.c50
-rw-r--r--src/or/connection_edge.h4
4 files changed, 45 insertions, 21 deletions
diff --git a/changes/bug17876 b/changes/bug17876
new file mode 100644
index 0000000000..1bd3dd7c1b
--- /dev/null
+++ b/changes/bug17876
@@ -0,0 +1,5 @@
+ o Minor bugfixes:
+ - When closing an entry connection, generate a warning if we should
+ have sent an end cell for it but we haven't. Fixes bug 17876;
+ bugfix on 0.2.3.2-alpha.
+
diff --git a/src/or/connection.c b/src/or/connection.c
index d6e5fcb277..b4cd4cdddb 100644
--- a/src/or/connection.c
+++ b/src/or/connection.c
@@ -678,6 +678,13 @@ connection_free,(connection_t *conn))
if (conn->type == CONN_TYPE_CONTROL) {
connection_control_closed(TO_CONTROL_CONN(conn));
}
+#if 1
+ /* DEBUGGING */
+ if (conn->type == CONN_TYPE_AP) {
+ connection_ap_warn_and_unmark_if_pending_circ(TO_ENTRY_CONN(conn),
+ "connection_free");
+ }
+#endif
connection_unregister_events(conn);
connection_free_(conn);
}
diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c
index 961e49abd9..8a3beb3ce9 100644
--- a/src/or/connection_edge.c
+++ b/src/or/connection_edge.c
@@ -527,27 +527,6 @@ connection_edge_about_to_close(edge_connection_t *edge_conn)
conn->marked_for_close_file, conn->marked_for_close);
tor_fragile_assert();
}
-
- if (TO_CONN(edge_conn)->type != CONN_TYPE_AP ||
- PREDICT_UNLIKELY(NULL == pending_entry_connections))
- return;
-
- entry_connection_t *entry_conn = EDGE_TO_ENTRY_CONN(edge_conn);
-
- if (TO_CONN(edge_conn)->state == AP_CONN_STATE_CIRCUIT_WAIT) {
- smartlist_remove(pending_entry_connections, entry_conn);
- }
-
-#if 1
- /* Check to make sure that this isn't in pending_entry_connections if it
- * didn't actually belong there. */
- if (TO_CONN(edge_conn)->type == CONN_TYPE_AP &&
- smartlist_contains(pending_entry_connections, entry_conn)) {
- log_warn(LD_BUG, "What was %p doing in pending_entry_connections???",
- entry_conn);
- smartlist_remove(pending_entry_connections, entry_conn);
- }
-#endif
}
/** Called when we're about to finally unlink and free an AP (client)
@@ -559,6 +538,8 @@ connection_ap_about_to_close(entry_connection_t *entry_conn)
edge_connection_t *edge_conn = ENTRY_TO_EDGE_CONN(entry_conn);
connection_t *conn = ENTRY_TO_CONN(entry_conn);
+ connection_edge_about_to_close(edge_conn);
+
if (entry_conn->socks_request->has_finished == 0) {
/* since conn gets removed right after this function finishes,
* there's no point trying to send back a reply at this point. */
@@ -577,6 +558,20 @@ connection_ap_about_to_close(entry_connection_t *entry_conn)
conn->marked_for_close_file, conn->marked_for_close);
dnsserv_reject_request(entry_conn);
}
+
+ if (TO_CONN(edge_conn)->state == AP_CONN_STATE_CIRCUIT_WAIT) {
+ smartlist_remove(pending_entry_connections, entry_conn);
+ }
+
+#if 1
+ /* Check to make sure that this isn't in pending_entry_connections if it
+ * didn't actually belong there. */
+ if (TO_CONN(edge_conn)->type == CONN_TYPE_AP) {
+ connection_ap_warn_and_unmark_if_pending_circ(entry_conn,
+ "about_to_close");
+ }
+#endif
+
control_event_stream_bandwidth(edge_conn);
control_event_stream_status(entry_conn, STREAM_EVENT_CLOSED,
edge_conn->end_reason);
@@ -906,6 +901,19 @@ connection_ap_mark_as_non_pending_circuit(entry_connection_t *entry_conn)
smartlist_remove(pending_entry_connections, entry_conn);
}
+/** DOCDOC */
+void
+connection_ap_warn_and_unmark_if_pending_circ(entry_connection_t *entry_conn,
+ const char *where)
+{
+ if (pending_entry_connections &&
+ smartlist_contains(pending_entry_connections, entry_conn)) {
+ log_warn(LD_BUG, "What was %p doing in pending_entry_connections in %s?",
+ entry_conn, where);
+ connection_ap_mark_as_non_pending_circuit(entry_conn);
+ }
+}
+
/** Tell any AP streams that are waiting for a one-hop tunnel to
* <b>failed_digest</b> that they are going to fail. */
/* XXX024 We should get rid of this function, and instead attach
diff --git a/src/or/connection_edge.h b/src/or/connection_edge.h
index 6da51eb0c6..2aba801461 100644
--- a/src/or/connection_edge.h
+++ b/src/or/connection_edge.h
@@ -115,6 +115,10 @@ streamid_t get_unique_stream_id_by_circ(origin_circuit_t *circ);
void connection_edge_free_all(void);
+void connection_ap_warn_and_unmark_if_pending_circ(
+ entry_connection_t *entry_conn,
+ const char *where);
+
/** @name Begin-cell flags
*
* These flags are used in RELAY_BEGIN cells to change the default behavior