aboutsummaryrefslogtreecommitdiff
path: root/src/or/onion.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2008-02-05 23:20:49 +0000
committerNick Mathewson <nickm@torproject.org>2008-02-05 23:20:49 +0000
commit12071df6c88415e60c990f230dcb67635431aafa (patch)
tree161c07b560b5e3464ce99ba98fe29c944a7ba8c7 /src/or/onion.c
parentff9bd0fd3a0acd38e495a3ff7c85011b51c9fcb6 (diff)
downloadtor-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/onion.c')
-rw-r--r--src/or/onion.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/or/onion.c b/src/or/onion.c
index fb516da242..c91b7d556b 100644
--- a/src/or/onion.c
+++ b/src/or/onion.c
@@ -19,6 +19,7 @@ const char onion_c_id[] =
* to process a waiting onion handshake. */
typedef struct onion_queue_t {
or_circuit_t *circ;
+ char *onionskin;
time_t when_added;
struct onion_queue_t *next;
} onion_queue_t;
@@ -37,13 +38,14 @@ static int ol_length=0;
* if ol_list is too long, in which case do nothing and return -1.
*/
int
-onion_pending_add(or_circuit_t *circ)
+onion_pending_add(or_circuit_t *circ, char *onionskin)
{
onion_queue_t *tmp;
time_t now = time(NULL);
tmp = tor_malloc_zero(sizeof(onion_queue_t));
tmp->circ = circ;
+ tmp->onionskin = onionskin;
tmp->when_added = now;
if (!ol_tail) {
@@ -86,7 +88,7 @@ onion_pending_add(or_circuit_t *circ)
* NULL if the list is empty.
*/
or_circuit_t *
-onion_next_task(void)
+onion_next_task(char **onionskin_out)
{
or_circuit_t *circ;
@@ -97,6 +99,8 @@ onion_next_task(void)
tor_assert(ol_list->circ->p_conn); /* make sure it's still valid */
tor_assert(ol_length > 0);
circ = ol_list->circ;
+ *onionskin_out = ol_list->onionskin;
+ ol_list->onionskin = NULL; /* prevent free. */
onion_pending_remove(ol_list->circ);
return circ;
}
@@ -139,6 +143,7 @@ onion_pending_remove(or_circuit_t *circ)
/* now victim points to the element that needs to be removed */
+ tor_free(victim->onionskin);
tor_free(victim);
}
@@ -448,6 +453,7 @@ clear_pending_onions(void)
while (ol_list) {
onion_queue_t *victim = ol_list;
ol_list = victim->next;
+ tor_free(victim->onionskin);
tor_free(victim);
}
ol_list = ol_tail = NULL;