More debugging code to try to track down #17659

This commit is contained in:
Nick Mathewson 2015-12-16 08:37:40 -05:00
parent a4ca2ef1ff
commit a03469aa85
2 changed files with 35 additions and 3 deletions

View File

@ -780,6 +780,15 @@ connection_ap_rescan_and_attach_pending(void)
connection_ap_attach_pending(1);
}
#ifdef DEBUGGING_17659
#define UNMARK() do { \
entry_conn->marked_pending_circ_line = 0; \
entry_conn->marked_pending_circ_file = 0; \
} while (0)
#else
#define UNMARK() do { } while (0)
#endif
/** Tell any AP streams that are listed as waiting for a new circuit to try
* again, either attaching to an available circ or launching a new one.
*
@ -801,12 +810,14 @@ connection_ap_attach_pending(int retry)
connection_t *conn = ENTRY_TO_CONN(entry_conn);
tor_assert(conn && entry_conn);
if (conn->marked_for_close) {
UNMARK();
SMARTLIST_DEL_CURRENT(pending_entry_connections, entry_conn);
continue;
}
if (conn->magic != ENTRY_CONNECTION_MAGIC) {
log_warn(LD_BUG, "%p has impossible magic value %u",
log_warn(LD_BUG, "%p has impossible magic value %u.",
entry_conn, (unsigned)conn->magic);
UNMARK();
SMARTLIST_DEL_CURRENT(pending_entry_connections, entry_conn);
continue;
}
@ -815,6 +826,7 @@ connection_ap_attach_pending(int retry)
"is %s. Why is it on pending_entry_connections?",
entry_conn,
conn_state_to_string(conn->type, conn->state));
UNMARK();
SMARTLIST_DEL_CURRENT(pending_entry_connections, entry_conn);
continue;
}
@ -828,6 +840,7 @@ connection_ap_attach_pending(int retry)
if (conn->marked_for_close ||
conn->type != CONN_TYPE_AP ||
conn->state != AP_CONN_STATE_CIRCUIT_WAIT) {
UNMARK();
SMARTLIST_DEL_CURRENT(pending_entry_connections, entry_conn);
continue;
}
@ -862,12 +875,23 @@ connection_ap_mark_as_pending_circuit_(entry_connection_t *entry_conn,
if (PREDICT_UNLIKELY(smartlist_contains(pending_entry_connections,
entry_conn))) {
log_warn(LD_BUG, "What?? pending_entry_connections already contains %p! "
"(called from %s:%d)",
"(Called from %s:%d.)",
entry_conn, fname, lineno);
log_backtrace(LOG_WARN, LD_BUG, "To debug, this may help.");
#ifdef DEBUGGING_17659
const char *f2 = entry_conn->marked_pending_circ_file;
log_warn(LD_BUG, "(Previously called from %s:%d.)\n",
f2 ? f2 : "<NULL>",
entry_conn->marked_pending_circ_line);
#endif
log_backtrace(LOG_WARN, LD_BUG, "To debug, this may help");
return;
}
#ifdef DEBUGGING_17659
entry_conn->marked_pending_circ_line = (uint16_t) lineno;
entry_conn->marked_pending_circ_file = fname;
#endif
untried_pending_connections = 1;
smartlist_add(pending_entry_connections, entry_conn);
}
@ -878,6 +902,7 @@ connection_ap_mark_as_non_pending_circuit(entry_connection_t *entry_conn)
{
if (PREDICT_UNLIKELY(NULL == pending_entry_connections))
return;
UNMARK();
smartlist_remove(pending_entry_connections, entry_conn);
}

View File

@ -1646,6 +1646,13 @@ typedef struct entry_connection_t {
* request that we're going to try to answer. */
struct evdns_server_request *dns_server_request;
#define DEBUGGING_17659
#ifdef DEBUGGING_17659
uint16_t marked_pending_circ_line;
const char *marked_pending_circ_file;
#endif
#define NUM_CIRCUITS_LAUNCHED_THRESHOLD 10
/** Number of times we've launched a circuit to handle this stream. If
* it gets too high, that could indicate an inconsistency between our