diff options
Diffstat (limited to 'src/dht/dht_api.c')
-rw-r--r-- | src/dht/dht_api.c | 52 |
1 files changed, 20 insertions, 32 deletions
diff --git a/src/dht/dht_api.c b/src/dht/dht_api.c index 720e82a41..ac69b7a4e 100644 --- a/src/dht/dht_api.c +++ b/src/dht/dht_api.c | |||
@@ -249,12 +249,11 @@ add_request_to_pending (void *cls, const GNUNET_HashCode * key, void *value) | |||
249 | struct GNUNET_DHT_GetHandle *rh = value; | 249 | struct GNUNET_DHT_GetHandle *rh = value; |
250 | 250 | ||
251 | if (GNUNET_NO == rh->message->in_pending_queue) | 251 | if (GNUNET_NO == rh->message->in_pending_queue) |
252 | { | 252 | { |
253 | #if DEBUG_DHT | 253 | #if DEBUG_DHT |
254 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 254 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
255 | "Retransmitting request related to %s to DHT %p\n", | 255 | "Retransmitting request related to %s to DHT %p\n", GNUNET_h2s (key), |
256 | GNUNET_h2s (key), | 256 | handle); |
257 | handle); | ||
258 | #endif | 257 | #endif |
259 | GNUNET_CONTAINER_DLL_insert (handle->pending_head, handle->pending_tail, | 258 | GNUNET_CONTAINER_DLL_insert (handle->pending_head, handle->pending_tail, |
260 | rh->message); | 259 | rh->message); |
@@ -284,9 +283,7 @@ try_reconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
284 | struct GNUNET_DHT_Handle *handle = cls; | 283 | struct GNUNET_DHT_Handle *handle = cls; |
285 | 284 | ||
286 | #if DEBUG_DHT | 285 | #if DEBUG_DHT |
287 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 286 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Reconnecting with DHT %p\n", handle); |
288 | "Reconnecting with DHT %p\n", | ||
289 | handle); | ||
290 | #endif | 287 | #endif |
291 | handle->reconnect_task = GNUNET_SCHEDULER_NO_TASK; | 288 | handle->reconnect_task = GNUNET_SCHEDULER_NO_TASK; |
292 | if (handle->retry_time.rel_value < GNUNET_CONSTANTS_SERVICE_RETRY.rel_value) | 289 | if (handle->retry_time.rel_value < GNUNET_CONSTANTS_SERVICE_RETRY.rel_value) |
@@ -324,8 +321,8 @@ do_disconnect (struct GNUNET_DHT_Handle *handle) | |||
324 | GNUNET_CLIENT_notify_transmit_ready_cancel (handle->th); | 321 | GNUNET_CLIENT_notify_transmit_ready_cancel (handle->th); |
325 | handle->th = NULL; | 322 | handle->th = NULL; |
326 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 323 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
327 | "Disconnecting from DHT service, will try to reconnect in %llu ms\n", | 324 | "Disconnecting from DHT service, will try to reconnect in %llu ms\n", |
328 | (unsigned long long) handle->retry_time.rel_value); | 325 | (unsigned long long) handle->retry_time.rel_value); |
329 | GNUNET_CLIENT_disconnect (handle->client, GNUNET_NO); | 326 | GNUNET_CLIENT_disconnect (handle->client, GNUNET_NO); |
330 | handle->client = NULL; | 327 | handle->client = NULL; |
331 | handle->reconnect_task = | 328 | handle->reconnect_task = |
@@ -351,7 +348,7 @@ process_pending_messages (struct GNUNET_DHT_Handle *handle) | |||
351 | if (handle->client == NULL) | 348 | if (handle->client == NULL) |
352 | { | 349 | { |
353 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 350 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
354 | "process_pending_messages called, but client is null, reconnecting\n"); | 351 | "process_pending_messages called, but client is null, reconnecting\n"); |
355 | do_disconnect (handle); | 352 | do_disconnect (handle); |
356 | return; | 353 | return; |
357 | } | 354 | } |
@@ -368,7 +365,7 @@ process_pending_messages (struct GNUNET_DHT_Handle *handle) | |||
368 | if (NULL != handle->th) | 365 | if (NULL != handle->th) |
369 | return; | 366 | return; |
370 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 367 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
371 | "notify_transmit_ready returned NULL, reconnecting\n"); | 368 | "notify_transmit_ready returned NULL, reconnecting\n"); |
372 | do_disconnect (handle); | 369 | do_disconnect (handle); |
373 | } | 370 | } |
374 | 371 | ||
@@ -432,7 +429,7 @@ transmit_pending (void *cls, size_t size, void *buf) | |||
432 | #endif | 429 | #endif |
433 | handle->in_receive = GNUNET_YES; | 430 | handle->in_receive = GNUNET_YES; |
434 | GNUNET_CLIENT_receive (handle->client, &service_message_handler, handle, | 431 | GNUNET_CLIENT_receive (handle->client, &service_message_handler, handle, |
435 | GNUNET_TIME_UNIT_FOREVER_REL); | 432 | GNUNET_TIME_UNIT_FOREVER_REL); |
436 | } | 433 | } |
437 | return tsize; | 434 | return tsize; |
438 | } | 435 | } |
@@ -466,9 +463,8 @@ process_reply (void *cls, const GNUNET_HashCode * key, void *value) | |||
466 | { | 463 | { |
467 | /* UID mismatch */ | 464 | /* UID mismatch */ |
468 | #if DEBUG_DHT | 465 | #if DEBUG_DHT |
469 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 466 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
470 | "Ignoring reply for %s: UID mismatch: %llu/%llu\n", | 467 | "Ignoring reply for %s: UID mismatch: %llu/%llu\n", GNUNET_h2s (key), |
471 | GNUNET_h2s (key), | ||
472 | dht_msg->unique_id, get_handle->unique_id); | 468 | dht_msg->unique_id, get_handle->unique_id); |
473 | #endif | 469 | #endif |
474 | return GNUNET_YES; | 470 | return GNUNET_YES; |
@@ -490,10 +486,8 @@ process_reply (void *cls, const GNUNET_HashCode * key, void *value) | |||
490 | } | 486 | } |
491 | data_length = msize - meta_length; | 487 | data_length = msize - meta_length; |
492 | #if DEBUG_DHT | 488 | #if DEBUG_DHT |
493 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 489 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Giving %u byte reply for %s to application\n", |
494 | "Giving %u byte reply for %s to application\n", | 490 | (unsigned int) data_length, GNUNET_h2s (key)); |
495 | (unsigned int) data_length, | ||
496 | GNUNET_h2s (key)); | ||
497 | #endif | 491 | #endif |
498 | put_path = (const struct GNUNET_PeerIdentity *) &dht_msg[1]; | 492 | put_path = (const struct GNUNET_PeerIdentity *) &dht_msg[1]; |
499 | get_path = &put_path[put_path_length]; | 493 | get_path = &put_path[put_path_length]; |
@@ -542,10 +536,8 @@ service_message_handler (void *cls, const struct GNUNET_MessageHeader *msg) | |||
542 | } | 536 | } |
543 | dht_msg = (const struct GNUNET_DHT_ClientResultMessage *) msg; | 537 | dht_msg = (const struct GNUNET_DHT_ClientResultMessage *) msg; |
544 | #if DEBUG_DHT | 538 | #if DEBUG_DHT |
545 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 539 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Received reply for `%s' from DHT service %p\n", |
546 | "Received reply for `%s' from DHT service %p\n", | 540 | GNUNET_h2s (&dht_msg->key), handle); |
547 | GNUNET_h2s (&dht_msg->key), | ||
548 | handle); | ||
549 | #endif | 541 | #endif |
550 | GNUNET_CONTAINER_multihashmap_get_multiple (handle->active_requests, | 542 | GNUNET_CONTAINER_multihashmap_get_multiple (handle->active_requests, |
551 | &dht_msg->key, &process_reply, | 543 | &dht_msg->key, &process_reply, |
@@ -641,7 +633,7 @@ timeout_put_request (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
641 | struct GNUNET_DHT_Handle *handle; | 633 | struct GNUNET_DHT_Handle *handle; |
642 | 634 | ||
643 | handle = pending->handle; | 635 | handle = pending->handle; |
644 | GNUNET_assert (GNUNET_YES == pending->in_pending_queue); | 636 | GNUNET_assert (GNUNET_YES == pending->in_pending_queue); |
645 | GNUNET_CONTAINER_DLL_remove (handle->pending_head, handle->pending_tail, | 637 | GNUNET_CONTAINER_DLL_remove (handle->pending_head, handle->pending_tail, |
646 | pending); | 638 | pending); |
647 | pending->in_pending_queue = GNUNET_NO; | 639 | pending->in_pending_queue = GNUNET_NO; |
@@ -752,10 +744,8 @@ GNUNET_DHT_get_start (struct GNUNET_DHT_Handle *handle, | |||
752 | return NULL; | 744 | return NULL; |
753 | } | 745 | } |
754 | #if DEBUG_DHT | 746 | #if DEBUG_DHT |
755 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 747 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Sending query for %s to DHT %p\n", |
756 | "Sending query for %s to DHT %p\n", | 748 | GNUNET_h2s (key), handle); |
757 | GNUNET_h2s (key), | ||
758 | handle); | ||
759 | #endif | 749 | #endif |
760 | pending = GNUNET_malloc (sizeof (struct PendingMessage) + msize); | 750 | pending = GNUNET_malloc (sizeof (struct PendingMessage) + msize); |
761 | get_msg = (struct GNUNET_DHT_ClientGetMessage *) &pending[1]; | 751 | get_msg = (struct GNUNET_DHT_ClientGetMessage *) &pending[1]; |
@@ -803,10 +793,8 @@ GNUNET_DHT_get_stop (struct GNUNET_DHT_GetHandle *get_handle) | |||
803 | get_msg = | 793 | get_msg = |
804 | (const struct GNUNET_DHT_ClientGetMessage *) get_handle->message->msg; | 794 | (const struct GNUNET_DHT_ClientGetMessage *) get_handle->message->msg; |
805 | #if DEBUG_DHT | 795 | #if DEBUG_DHT |
806 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 796 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Sending STOP for %s to DHT via %p\n", |
807 | "Sending STOP for %s to DHT via %p\n", | 797 | GNUNET_h2s (&get_msg->key), handle); |
808 | GNUNET_h2s (&get_msg->key), | ||
809 | handle); | ||
810 | #endif | 798 | #endif |
811 | /* generate STOP */ | 799 | /* generate STOP */ |
812 | pending = | 800 | pending = |