aboutsummaryrefslogtreecommitdiff
path: root/src/dht/gnunet-service-dht_clients.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/dht/gnunet-service-dht_clients.c')
-rw-r--r--src/dht/gnunet-service-dht_clients.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/dht/gnunet-service-dht_clients.c b/src/dht/gnunet-service-dht_clients.c
index 6f7c1daae..4b9eecc58 100644
--- a/src/dht/gnunet-service-dht_clients.c
+++ b/src/dht/gnunet-service-dht_clients.c
@@ -248,10 +248,12 @@ remove_client_records (void *cls, const GNUNET_HashCode * key, void *value)
248 248
249 if (record->client != client) 249 if (record->client != client)
250 return GNUNET_YES; 250 return GNUNET_YES;
251#if DEBUG_DHT
251 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 252 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
252 "Removing client %p's record for key %s\n", 253 "Removing client %p's record for key %s\n",
253 client, 254 client,
254 GNUNET_h2s (key)); 255 GNUNET_h2s (key));
256#endif
255 GNUNET_assert (GNUNET_YES == 257 GNUNET_assert (GNUNET_YES ==
256 GNUNET_CONTAINER_multihashmap_remove (forward_map, 258 GNUNET_CONTAINER_multihashmap_remove (forward_map,
257 key, record)); 259 key, record));
@@ -280,9 +282,11 @@ handle_client_disconnect (void *cls,
280 struct ClientList *pos; 282 struct ClientList *pos;
281 struct PendingMessage *reply; 283 struct PendingMessage *reply;
282 284
285#if DEBUG_DHT
283 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 286 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
284 "Local client %p disconnects\n", 287 "Local client %p disconnects\n",
285 client); 288 client);
289#endif
286 pos = find_active_client (client); 290 pos = find_active_client (client);
287 GNUNET_CONTAINER_DLL_remove (client_head, 291 GNUNET_CONTAINER_DLL_remove (client_head,
288 client_tail, 292 client_tail,
@@ -410,10 +414,12 @@ handle_dht_local_put (void *cls, struct GNUNET_SERVER_Client *client,
410 GNUNET_NO); 414 GNUNET_NO);
411 dht_msg = (const struct GNUNET_DHT_ClientPutMessage *) message; 415 dht_msg = (const struct GNUNET_DHT_ClientPutMessage *) message;
412 /* give to local clients */ 416 /* give to local clients */
417#if DEBUG_DHT
413 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 418 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
414 "Handling local PUT of %u-bytes for query %s\n", 419 "Handling local PUT of %u-bytes for query %s\n",
415 size - sizeof (struct GNUNET_DHT_ClientPutMessage), 420 size - sizeof (struct GNUNET_DHT_ClientPutMessage),
416 GNUNET_h2s (&dht_msg->key)); 421 GNUNET_h2s (&dht_msg->key));
422#endif
417 GDS_CLIENTS_handle_reply (GNUNET_TIME_absolute_ntoh (dht_msg->expiration), 423 GDS_CLIENTS_handle_reply (GNUNET_TIME_absolute_ntoh (dht_msg->expiration),
418 &dht_msg->key, 424 &dht_msg->key,
419 0, NULL, 425 0, NULL,
@@ -479,10 +485,12 @@ handle_dht_local_get (void *cls, struct GNUNET_SERVER_Client *client,
479 GNUNET_STATISTICS_update (GDS_stats, 485 GNUNET_STATISTICS_update (GDS_stats,
480 gettext_noop ("# GET requests received from clients"), 1, 486 gettext_noop ("# GET requests received from clients"), 1,
481 GNUNET_NO); 487 GNUNET_NO);
488#if DEBUG_DHT
482 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 489 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
483 "Received request for %s from local client %p\n", 490 "Received request for %s from local client %p\n",
484 GNUNET_h2s (&get->key), 491 GNUNET_h2s (&get->key),
485 client); 492 client);
493#endif
486 cqr = GNUNET_malloc (sizeof (struct ClientQueryRecord) + xquery_size); 494 cqr = GNUNET_malloc (sizeof (struct ClientQueryRecord) + xquery_size);
487 cqr->key = get->key; 495 cqr->key = get->key;
488 cqr->client = find_active_client (client); 496 cqr->client = find_active_client (client);
@@ -546,10 +554,12 @@ remove_by_unique_id (void *cls, const GNUNET_HashCode * key, void *value)
546 554
547 if (record->unique_id != ctx->unique_id) 555 if (record->unique_id != ctx->unique_id)
548 return GNUNET_YES; 556 return GNUNET_YES;
557#if DEBUG_DHT
549 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 558 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
550 "Removing client %p's record for key %s (by unique id)\n", 559 "Removing client %p's record for key %s (by unique id)\n",
551 ctx->client->client_handle, 560 ctx->client->client_handle,
552 GNUNET_h2s (key)); 561 GNUNET_h2s (key));
562#endif
553 return remove_client_records (ctx->client, key, record); 563 return remove_client_records (ctx->client, key, record);
554} 564}
555 565
@@ -574,10 +584,12 @@ handle_dht_local_get_stop (void *cls, struct GNUNET_SERVER_Client *client,
574 GNUNET_STATISTICS_update (GDS_stats, 584 GNUNET_STATISTICS_update (GDS_stats,
575 gettext_noop ("# GET STOP requests received from clients"), 1, 585 gettext_noop ("# GET STOP requests received from clients"), 1,
576 GNUNET_NO); 586 GNUNET_NO);
587#if DEBUG_DHT
577 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 588 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
578 "Client %p stopped request for key %s\n", 589 "Client %p stopped request for key %s\n",
579 client, 590 client,
580 GNUNET_h2s (&dht_stop_msg->key)); 591 GNUNET_h2s (&dht_stop_msg->key));
592#endif
581 ctx.client = find_active_client (client); 593 ctx.client = find_active_client (client);
582 ctx.unique_id = dht_stop_msg->unique_id; 594 ctx.unique_id = dht_stop_msg->unique_id;
583 GNUNET_CONTAINER_multihashmap_get_multiple (forward_map, 595 GNUNET_CONTAINER_multihashmap_get_multiple (forward_map,
@@ -622,9 +634,11 @@ send_reply_to_client (void *cls, size_t size, void *buf)
622 if (buf == NULL) 634 if (buf == NULL)
623 { 635 {
624 /* client disconnected */ 636 /* client disconnected */
637#if DEBUG_DHT
625 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 638 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
626 "Client %p disconnected, pending messages will be discarded\n", 639 "Client %p disconnected, pending messages will be discarded\n",
627 client->client_handle); 640 client->client_handle);
641#endif
628 return 0; 642 return 0;
629 } 643 }
630 off = 0; 644 off = 0;
@@ -635,18 +649,22 @@ send_reply_to_client (void *cls, size_t size, void *buf)
635 reply); 649 reply);
636 memcpy (&cbuf[off], reply->msg, msize); 650 memcpy (&cbuf[off], reply->msg, msize);
637 GNUNET_free (reply); 651 GNUNET_free (reply);
652#if DEBUG_DHT
638 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 653 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
639 "Transmitting %u bytes to client %p\n", 654 "Transmitting %u bytes to client %p\n",
640 msize, 655 msize,
641 client->client_handle); 656 client->client_handle);
657#endif
642 off += msize; 658 off += msize;
643 } 659 }
644 process_pending_messages (client); 660 process_pending_messages (client);
661#if DEBUG_DHT
645 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 662 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
646 "Transmitted %u/%u bytes to client %p\n", 663 "Transmitted %u/%u bytes to client %p\n",
647 (unsigned int) off, 664 (unsigned int) off,
648 (unsigned int) size, 665 (unsigned int) size,
649 client->client_handle); 666 client->client_handle);
667#endif
650 return off; 668 return off;
651} 669}
652 670
@@ -661,19 +679,23 @@ process_pending_messages (struct ClientList *client)
661{ 679{
662 if ((client->pending_head == NULL) || (client->transmit_handle != NULL)) 680 if ((client->pending_head == NULL) || (client->transmit_handle != NULL))
663 { 681 {
682#if DEBUG_DHT
664 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 683 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
665 "Not asking for transmission to %p now: %s\n", 684 "Not asking for transmission to %p now: %s\n",
666 client->client_handle, 685 client->client_handle,
667 client->pending_head == NULL 686 client->pending_head == NULL
668 ? "no more messages" 687 ? "no more messages"
669 : "request already pending"); 688 : "request already pending");
689#endif
670 return; 690 return;
671 } 691 }
692#if DEBUG_DHT
672 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 693 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
673 "Asking for transmission of %u bytes to client %p\n", 694 "Asking for transmission of %u bytes to client %p\n",
674 ntohs (client->pending_head-> 695 ntohs (client->pending_head->
675 msg->size), 696 msg->size),
676 client->client_handle); 697 client->client_handle);
698#endif
677 client->transmit_handle = 699 client->transmit_handle =
678 GNUNET_SERVER_notify_transmit_ready (client->client_handle, 700 GNUNET_SERVER_notify_transmit_ready (client->client_handle,
679 ntohs (client->pending_head-> 701 ntohs (client->pending_head->
@@ -759,9 +781,11 @@ forward_reply (void *cls, const GNUNET_HashCode * key, void *value)
759 if ( (record->type != GNUNET_BLOCK_TYPE_ANY) && 781 if ( (record->type != GNUNET_BLOCK_TYPE_ANY) &&
760 (record->type != frc->type) ) 782 (record->type != frc->type) )
761 { 783 {
784#if DEBUG_DHT
762 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 785 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
763 "Record type missmatch, not passing request for key %s to local client\n", 786 "Record type missmatch, not passing request for key %s to local client\n",
764 GNUNET_h2s (key)); 787 GNUNET_h2s (key));
788#endif
765 GNUNET_STATISTICS_update (GDS_stats, 789 GNUNET_STATISTICS_update (GDS_stats,
766 gettext_noop ("# Key match, type mismatches in REPLY to CLIENT"), 1, 790 gettext_noop ("# Key match, type mismatches in REPLY to CLIENT"), 1,
767 GNUNET_NO); 791 GNUNET_NO);
@@ -775,9 +799,11 @@ forward_reply (void *cls, const GNUNET_HashCode * key, void *value)
775 &ch, 799 &ch,
776 sizeof (GNUNET_HashCode))) 800 sizeof (GNUNET_HashCode)))
777 { 801 {
802#if DEBUG_DHT
778 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 803 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
779 "Duplicate reply, not passing request for key %s to local client\n", 804 "Duplicate reply, not passing request for key %s to local client\n",
780 GNUNET_h2s (key)); 805 GNUNET_h2s (key));
806#endif
781 GNUNET_STATISTICS_update (GDS_stats, 807 GNUNET_STATISTICS_update (GDS_stats,
782 gettext_noop ("# Duplicate REPLIES to CLIENT request dropped"), 1, 808 gettext_noop ("# Duplicate REPLIES to CLIENT request dropped"), 1,
783 GNUNET_NO); 809 GNUNET_NO);
@@ -791,10 +817,12 @@ forward_reply (void *cls, const GNUNET_HashCode * key, void *value)
791 record->xquery_size, 817 record->xquery_size,
792 frc->data, 818 frc->data,
793 frc->data_size); 819 frc->data_size);
820#if DEBUG_DHT
794 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 821 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
795 "Evaluation result is %d for key %s for local client's query\n", 822 "Evaluation result is %d for key %s for local client's query\n",
796 (int) eval, 823 (int) eval,
797 GNUNET_h2s (key)); 824 GNUNET_h2s (key));
825#endif
798 switch (eval) 826 switch (eval)
799 { 827 {
800 case GNUNET_BLOCK_EVALUATION_OK_LAST: 828 case GNUNET_BLOCK_EVALUATION_OK_LAST:
@@ -848,10 +876,12 @@ forward_reply (void *cls, const GNUNET_HashCode * key, void *value)
848 GNUNET_NO); 876 GNUNET_NO);
849 reply = (struct GNUNET_DHT_ClientResultMessage*) &pm[1]; 877 reply = (struct GNUNET_DHT_ClientResultMessage*) &pm[1];
850 reply->unique_id = record->unique_id; 878 reply->unique_id = record->unique_id;
879#if DEBUG_DHT
851 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 880 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
852 "Queueing reply to query %s for client %p\n", 881 "Queueing reply to query %s for client %p\n",
853 GNUNET_h2s (key), 882 GNUNET_h2s (key),
854 record->client->client_handle); 883 record->client->client_handle);
884#endif
855 add_pending_message (record->client, pm); 885 add_pending_message (record->client, pm);
856 if (GNUNET_YES == do_free) 886 if (GNUNET_YES == do_free)
857 remove_client_records (record->client, key, record); 887 remove_client_records (record->client, key, record);