diff options
author | Nick Mathewson <nickm@torproject.org> | 2008-02-05 23:20:49 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2008-02-05 23:20:49 +0000 |
commit | 12071df6c88415e60c990f230dcb67635431aafa (patch) | |
tree | 161c07b560b5e3464ce99ba98fe29c944a7ba8c7 /src/or/cpuworker.c | |
parent | ff9bd0fd3a0acd38e495a3ff7c85011b51c9fcb6 (diff) | |
download | tor-12071df6c88415e60c990f230dcb67635431aafa.tar.gz tor-12071df6c88415e60c990f230dcb67635431aafa.zip |
r17930@catbus: nickm | 2008-02-05 18:20:40 -0500
Initial attempts to track down bug 600, and refactor possibly offending code. 1) complain early if circuit state is set to OPEN when an onionskin is pending. 2) refactor onionskin field into one only used when n_conn is pending, and a separate onionskin field waiting for attention by a cpuworker. This might even fix the bug. More likely, it will make it fail with a more useful core.
svn:r13394
Diffstat (limited to 'src/or/cpuworker.c')
-rw-r--r-- | src/or/cpuworker.c | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/src/or/cpuworker.c b/src/or/cpuworker.c index b1f56d3dbb..7d5cf679b5 100644 --- a/src/or/cpuworker.c +++ b/src/or/cpuworker.c @@ -387,15 +387,16 @@ static void process_pending_task(connection_t *cpuworker) { or_circuit_t *circ; + char *onionskin = NULL; tor_assert(cpuworker); /* for now only process onion tasks */ - circ = onion_next_task(); + circ = onion_next_task(&onionskin); if (!circ) return; - if (assign_to_cpuworker(cpuworker, CPUWORKER_TASK_ONION, circ) < 0) + if (assign_onionskin_to_cpuworker(cpuworker, circ, onionskin)) log_warn(LD_OR,"assign_to_cpuworker failed. Ignoring."); } @@ -433,28 +434,22 @@ cull_wedged_cpuworkers(void) /** 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. - * If question_type is CPUWORKER_TASK_ONION then task is a circ. - * No other question_types are allowed. + * DOCDOC this function is now less general */ int -assign_to_cpuworker(connection_t *cpuworker, uint8_t question_type, - void *task) +assign_onionskin_to_cpuworker(connection_t *cpuworker, + or_circuit_t *circ, char *onionskin) { - or_circuit_t *circ; + char qbuf[1]; char tag[TAG_LEN]; - tor_assert(question_type == CPUWORKER_TASK_ONION); - cull_wedged_cpuworkers(); spawn_enough_cpuworkers(); - if (question_type == CPUWORKER_TASK_ONION) { - circ = task; - tor_assert(circ->_base.onionskin); - + if (1) { if (num_cpuworkers_busy == num_cpuworkers) { log_debug(LD_OR,"No idle cpuworkers. Queuing."); - if (onion_pending_add(circ) < 0) + if (onion_pending_add(circ, onionskin) < 0) return -1; return 0; } @@ -467,6 +462,7 @@ assign_to_cpuworker(connection_t *cpuworker, uint8_t question_type, if (!circ->p_conn) { log_info(LD_OR,"circ->p_conn gone. Failing circ."); + tor_free(onionskin); return -1; } tag_pack(tag, circ->p_conn->_base.addr, circ->p_conn->_base.port, @@ -479,11 +475,11 @@ assign_to_cpuworker(connection_t *cpuworker, uint8_t question_type, cpuworker->timestamp_lastwritten = time(NULL); num_cpuworkers_busy++; - connection_write_to_buf((char*)&question_type, 1, cpuworker); + qbuf[0] = CPUWORKER_TASK_ONION; + connection_write_to_buf(qbuf, 1, cpuworker); connection_write_to_buf(tag, sizeof(tag), cpuworker); - connection_write_to_buf(circ->_base.onionskin, ONIONSKIN_CHALLENGE_LEN, - cpuworker); - tor_free(circ->_base.onionskin); + connection_write_to_buf(onionskin, ONIONSKIN_CHALLENGE_LEN, cpuworker); + tor_free(onionskin); } return 0; } |