[or-cvs] We have a bug that I can"t find. Sometimes, very rarely, cp...
Roger Dingledine
arma at seul.org
Thu Apr 7 20:02:03 UTC 2005
Update of /home2/or/cvsroot/tor/src/or
In directory moria.mit.edu:/home2/arma/work/onion/cvs/tor/src/or
Modified Files:
cpuworker.c
Log Message:
We have a bug that I can't find. Sometimes, very rarely, cpuworkers get
stuck in the 'busy' state, even though the cpuworker process thinks of
itself as idle. I don't know why. But here's a workaround to kill any
cpuworker that's been busy for more than 100 seconds.
Index: cpuworker.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/cpuworker.c,v
retrieving revision 1.72
retrieving revision 1.73
diff -u -d -r1.72 -r1.73
--- cpuworker.c 6 Apr 2005 15:19:32 -0000 1.72
+++ cpuworker.c 7 Apr 2005 20:02:00 -0000 1.73
@@ -356,6 +356,30 @@
log_fn(LOG_WARN,"assign_to_cpuworker failed. Ignoring.");
}
+#define CPUWORKER_BUSY_TIMEOUT 100 /* seconds */
+
+static void
+cull_wedged_cpuworkers(void) {
+ connection_t **carray;
+ connection_t *conn;
+ int n_conns, i;
+ time_t now = time(NULL);
+
+ get_connection_array(&carray, &n_conns);
+ for (i = 0; i < n_conns; ++i) {
+ conn = carray[i];
+ if (!conn->marked_for_close &&
+ conn->type == CONN_TYPE_CPUWORKER &&
+ conn->state == CPUWORKER_STATE_BUSY_ONION &&
+ conn->timestamp_lastwritten + CPUWORKER_BUSY_TIMEOUT > now) {
+ log_fn(LOG_NOTICE,"Bug: closing wedged cpuworker. Can somebody find the bug?");
+ num_cpuworkers_busy--;
+ num_cpuworkers--;
+ connection_mark_for_close(conn);
+ }
+ }
+}
+
/** If cpuworker is defined, assert that he's idle, and use him. Else,
* look for an idle cpuworker and use him. If none idle, queue task onto
* the pending onion list and return.
@@ -369,6 +393,9 @@
tor_assert(question_type == CPUWORKER_TASK_ONION);
+ cull_wedged_cpuworkers();
+ spawn_enough_cpuworkers();
+
if (question_type == CPUWORKER_TASK_ONION) {
circ = task;
More information about the tor-commits
mailing list