diff options
author | Christian Grothoff <christian@grothoff.org> | 2010-05-21 08:11:35 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2010-05-21 08:11:35 +0000 |
commit | 155efd5d4d3899e142c59f61943767c0ba5f9cfd (patch) | |
tree | be8dd9e887b37dcff6be1ab41849e703cb63ba2b /src/core | |
parent | 7afa921bf5d21f5b8260e71d7ec0d7927fb085e3 (diff) | |
download | gnunet-155efd5d4d3899e142c59f61943767c0ba5f9cfd.tar.gz gnunet-155efd5d4d3899e142c59f61943767c0ba5f9cfd.zip |
do not queue SETKEY messages twice
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/gnunet-service-core.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/core/gnunet-service-core.c b/src/core/gnunet-service-core.c index 5022cfc1b..25a49d3dc 100644 --- a/src/core/gnunet-service-core.c +++ b/src/core/gnunet-service-core.c | |||
@@ -381,6 +381,11 @@ struct MessageEntry | |||
381 | */ | 381 | */ |
382 | int8_t got_slack; | 382 | int8_t got_slack; |
383 | 383 | ||
384 | /** | ||
385 | * Is this a SETKEY message? | ||
386 | */ | ||
387 | int is_setkey; | ||
388 | |||
384 | }; | 389 | }; |
385 | 390 | ||
386 | 391 | ||
@@ -2440,6 +2445,7 @@ process_hello_retry_send_key (void *cls, | |||
2440 | static void | 2445 | static void |
2441 | send_key (struct Neighbour *n) | 2446 | send_key (struct Neighbour *n) |
2442 | { | 2447 | { |
2448 | struct MessageEntry *pos; | ||
2443 | struct SetKeyMessage *sm; | 2449 | struct SetKeyMessage *sm; |
2444 | struct MessageEntry *me; | 2450 | struct MessageEntry *me; |
2445 | struct PingMessage pp; | 2451 | struct PingMessage pp; |
@@ -2503,12 +2509,29 @@ send_key (struct Neighbour *n) | |||
2503 | &process_hello_retry_send_key, n); | 2509 | &process_hello_retry_send_key, n); |
2504 | return; | 2510 | return; |
2505 | } | 2511 | } |
2512 | pos = n->encrypted_head; | ||
2513 | while (pos != NULL) | ||
2514 | { | ||
2515 | if (GNUNET_YES == pos->is_setkey) | ||
2516 | { | ||
2517 | #if DEBUG_CORE | ||
2518 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2519 | "%s message for `%s' already in the queue, not adding another one\n", | ||
2520 | "SETKEY", | ||
2521 | GNUNET_i2s (&n->peer)); | ||
2522 | #endif | ||
2523 | return; | ||
2524 | } | ||
2525 | pos = pos->next; | ||
2526 | } | ||
2527 | |||
2506 | /* first, set key message */ | 2528 | /* first, set key message */ |
2507 | me = GNUNET_malloc (sizeof (struct MessageEntry) + | 2529 | me = GNUNET_malloc (sizeof (struct MessageEntry) + |
2508 | sizeof (struct SetKeyMessage)); | 2530 | sizeof (struct SetKeyMessage)); |
2509 | me->deadline = GNUNET_TIME_relative_to_absolute (MAX_SET_KEY_DELAY); | 2531 | me->deadline = GNUNET_TIME_relative_to_absolute (MAX_SET_KEY_DELAY); |
2510 | me->priority = SET_KEY_PRIORITY; | 2532 | me->priority = SET_KEY_PRIORITY; |
2511 | me->size = sizeof (struct SetKeyMessage); | 2533 | me->size = sizeof (struct SetKeyMessage); |
2534 | me->is_setkey = GNUNET_YES; | ||
2512 | GNUNET_CONTAINER_DLL_insert_after (n->encrypted_head, | 2535 | GNUNET_CONTAINER_DLL_insert_after (n->encrypted_head, |
2513 | n->encrypted_tail, | 2536 | n->encrypted_tail, |
2514 | n->encrypted_tail, | 2537 | n->encrypted_tail, |
@@ -2535,7 +2558,7 @@ send_key (struct Neighbour *n) | |||
2535 | GNUNET_assert (GNUNET_OK == | 2558 | GNUNET_assert (GNUNET_OK == |
2536 | GNUNET_CRYPTO_rsa_sign (my_private_key, &sm->purpose, | 2559 | GNUNET_CRYPTO_rsa_sign (my_private_key, &sm->purpose, |
2537 | &sm->signature)); | 2560 | &sm->signature)); |
2538 | 2561 | ||
2539 | /* second, encrypted PING message */ | 2562 | /* second, encrypted PING message */ |
2540 | me = GNUNET_malloc (sizeof (struct MessageEntry) + | 2563 | me = GNUNET_malloc (sizeof (struct MessageEntry) + |
2541 | sizeof (struct PingMessage)); | 2564 | sizeof (struct PingMessage)); |