aboutsummaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2010-05-21 08:11:35 +0000
committerChristian Grothoff <christian@grothoff.org>2010-05-21 08:11:35 +0000
commit155efd5d4d3899e142c59f61943767c0ba5f9cfd (patch)
treebe8dd9e887b37dcff6be1ab41849e703cb63ba2b /src/core
parent7afa921bf5d21f5b8260e71d7ec0d7927fb085e3 (diff)
downloadgnunet-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.c25
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,
2440static void 2445static void
2441send_key (struct Neighbour *n) 2446send_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));