aboutsummaryrefslogtreecommitdiff
path: root/src/core/core_api.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-10-10 13:36:10 +0000
committerChristian Grothoff <christian@grothoff.org>2011-10-10 13:36:10 +0000
commit3bff0d50c44e088e121ce00c603d290be41489d8 (patch)
treece7484b96ab286c3c63b4d7ef0741fc55306c35e /src/core/core_api.c
parentd9482088d0e83c9a8784a1042012fa71c0b7a65e (diff)
downloadgnunet-3bff0d50c44e088e121ce00c603d290be41489d8.tar.gz
gnunet-3bff0d50c44e088e121ce00c603d290be41489d8.zip
use LOG macro in core_api.c
Diffstat (limited to 'src/core/core_api.c')
-rw-r--r--src/core/core_api.c136
1 files changed, 67 insertions, 69 deletions
diff --git a/src/core/core_api.c b/src/core/core_api.c
index 78f606322..57d01f6bb 100644
--- a/src/core/core_api.c
+++ b/src/core/core_api.c
@@ -29,6 +29,7 @@
29#include "gnunet_core_service.h" 29#include "gnunet_core_service.h"
30#include "core.h" 30#include "core.h"
31 31
32#define LOG(kind,...) GNUNET_log_from (kind, "core-api",__VA_ARGS__)
32 33
33/** 34/**
34 * Information we track for each peer. 35 * Information we track for each peer.
@@ -367,8 +368,7 @@ reconnect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
367 368
368 h->reconnect_task = GNUNET_SCHEDULER_NO_TASK; 369 h->reconnect_task = GNUNET_SCHEDULER_NO_TASK;
369#if DEBUG_CORE 370#if DEBUG_CORE
370 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 371 LOG (GNUNET_ERROR_TYPE_DEBUG, "Connecting to CORE service after delay\n");
371 "Connecting to CORE service after delay\n");
372#endif 372#endif
373 reconnect (h); 373 reconnect (h);
374} 374}
@@ -547,9 +547,9 @@ request_next_transmission (struct PeerRecord *pr)
547 GNUNET_CONTAINER_DLL_insert_tail (h->control_pending_head, 547 GNUNET_CONTAINER_DLL_insert_tail (h->control_pending_head,
548 h->control_pending_tail, cm); 548 h->control_pending_tail, cm);
549#if DEBUG_CORE 549#if DEBUG_CORE
550 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 550 LOG (GNUNET_ERROR_TYPE_DEBUG,
551 "Adding SEND REQUEST for peer `%s' to message queue\n", 551 "Adding SEND REQUEST for peer `%s' to message queue\n",
552 GNUNET_i2s (&pr->peer)); 552 GNUNET_i2s (&pr->peer));
553#endif 553#endif
554 trigger_next_request (h, GNUNET_NO); 554 trigger_next_request (h, GNUNET_NO);
555} 555}
@@ -581,8 +581,8 @@ transmission_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
581 GNUNET_CONTAINER_DLL_remove (h->ready_peer_head, h->ready_peer_tail, pr); 581 GNUNET_CONTAINER_DLL_remove (h->ready_peer_head, h->ready_peer_tail, pr);
582 } 582 }
583#if DEBUG_CORE 583#if DEBUG_CORE
584 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 584 LOG (GNUNET_ERROR_TYPE_DEBUG,
585 "Signalling timeout of request for transmission to CORE service\n"); 585 "Signalling timeout of request for transmission to CORE service\n");
586#endif 586#endif
587 request_next_transmission (pr); 587 request_next_transmission (pr);
588 GNUNET_assert (0 == th->get_message (th->get_message_cls, 0, NULL)); 588 GNUNET_assert (0 == th->get_message (th->get_message_cls, 0, NULL));
@@ -610,8 +610,8 @@ transmit_message (void *cls, size_t size, void *buf)
610 if (buf == NULL) 610 if (buf == NULL)
611 { 611 {
612#if DEBUG_CORE 612#if DEBUG_CORE
613 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 613 LOG (GNUNET_ERROR_TYPE_DEBUG,
614 "Transmission failed, initiating reconnect\n"); 614 "Transmission failed, initiating reconnect\n");
615#endif 615#endif
616 reconnect_later (h); 616 reconnect_later (h);
617 return 0; 617 return 0;
@@ -627,9 +627,9 @@ transmit_message (void *cls, size_t size, void *buf)
627 return 0; 627 return 0;
628 } 628 }
629#if DEBUG_CORE 629#if DEBUG_CORE
630 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 630 LOG (GNUNET_ERROR_TYPE_DEBUG,
631 "Transmitting control message with %u bytes of type %u to core.\n", 631 "Transmitting control message with %u bytes of type %u to core.\n",
632 (unsigned int) msize, (unsigned int) ntohs (hdr->type)); 632 (unsigned int) msize, (unsigned int) ntohs (hdr->type));
633#endif 633#endif
634 memcpy (buf, hdr, msize); 634 memcpy (buf, hdr, msize);
635 GNUNET_CONTAINER_DLL_remove (h->control_pending_head, 635 GNUNET_CONTAINER_DLL_remove (h->control_pending_head,
@@ -661,9 +661,9 @@ transmit_message (void *cls, size_t size, void *buf)
661 pr->timeout_task = GNUNET_SCHEDULER_NO_TASK; 661 pr->timeout_task = GNUNET_SCHEDULER_NO_TASK;
662 } 662 }
663#if DEBUG_CORE 663#if DEBUG_CORE
664 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 664 LOG (GNUNET_ERROR_TYPE_DEBUG,
665 "Transmitting SEND request to `%s' with %u bytes.\n", 665 "Transmitting SEND request to `%s' with %u bytes.\n",
666 GNUNET_i2s (&pr->peer), (unsigned int) th->msize); 666 GNUNET_i2s (&pr->peer), (unsigned int) th->msize);
667#endif 667#endif
668 sm = (struct SendMessage *) buf; 668 sm = (struct SendMessage *) buf;
669 sm->header.type = htons (GNUNET_MESSAGE_TYPE_CORE_SEND); 669 sm->header.type = htons (GNUNET_MESSAGE_TYPE_CORE_SEND);
@@ -677,26 +677,26 @@ transmit_message (void *cls, size_t size, void *buf)
677 size - sizeof (struct SendMessage), &sm[1]); 677 size - sizeof (struct SendMessage), &sm[1]);
678 678
679#if DEBUG_CORE 679#if DEBUG_CORE
680 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 680 LOG (GNUNET_ERROR_TYPE_DEBUG,
681 "Transmitting SEND request to `%s' yielded %u bytes.\n", 681 "Transmitting SEND request to `%s' yielded %u bytes.\n",
682 GNUNET_i2s (&pr->peer), ret); 682 GNUNET_i2s (&pr->peer), ret);
683#endif 683#endif
684 GNUNET_free (th); 684 GNUNET_free (th);
685 if (0 == ret) 685 if (0 == ret)
686 { 686 {
687#if DEBUG_CORE 687#if DEBUG_CORE
688 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 688 LOG (GNUNET_ERROR_TYPE_DEBUG,
689 "Size of clients message to peer %s is 0!\n", 689 "Size of clients message to peer %s is 0!\n",
690 GNUNET_i2s (&pr->peer)); 690 GNUNET_i2s (&pr->peer));
691#endif 691#endif
692 /* client decided to send nothing! */ 692 /* client decided to send nothing! */
693 request_next_transmission (pr); 693 request_next_transmission (pr);
694 return 0; 694 return 0;
695 } 695 }
696#if DEBUG_CORE 696#if DEBUG_CORE
697 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 697 LOG (GNUNET_ERROR_TYPE_DEBUG,
698 "Produced SEND message to core with %u bytes payload\n", 698 "Produced SEND message to core with %u bytes payload\n",
699 (unsigned int) ret); 699 (unsigned int) ret);
700#endif 700#endif
701 GNUNET_assert (ret >= sizeof (struct GNUNET_MessageHeader)); 701 GNUNET_assert (ret >= sizeof (struct GNUNET_MessageHeader));
702 if (ret + sizeof (struct SendMessage) >= GNUNET_SERVER_MAX_MESSAGE_SIZE) 702 if (ret + sizeof (struct SendMessage) >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
@@ -730,16 +730,15 @@ trigger_next_request (struct GNUNET_CORE_Handle *h, int ignore_currently_down)
730 if ((GNUNET_YES == h->currently_down) && (ignore_currently_down == GNUNET_NO)) 730 if ((GNUNET_YES == h->currently_down) && (ignore_currently_down == GNUNET_NO))
731 { 731 {
732#if DEBUG_CORE 732#if DEBUG_CORE
733 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 733 LOG (GNUNET_ERROR_TYPE_DEBUG,
734 "Core connection down, not processing queue\n"); 734 "Core connection down, not processing queue\n");
735#endif 735#endif
736 return; 736 return;
737 } 737 }
738 if (NULL != h->cth) 738 if (NULL != h->cth)
739 { 739 {
740#if DEBUG_CORE 740#if DEBUG_CORE
741 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 741 LOG (GNUNET_ERROR_TYPE_DEBUG, "Request pending, not processing queue\n");
742 "Request pending, not processing queue\n");
743#endif 742#endif
744 return; 743 return;
745 } 744 }
@@ -753,8 +752,8 @@ trigger_next_request (struct GNUNET_CORE_Handle *h, int ignore_currently_down)
753 else 752 else
754 { 753 {
755#if DEBUG_CORE 754#if DEBUG_CORE
756 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 755 LOG (GNUNET_ERROR_TYPE_DEBUG,
757 "Request queue empty, not processing queue\n"); 756 "Request queue empty, not processing queue\n");
758#endif 757#endif
759 return; /* no pending message */ 758 return; /* no pending message */
760 } 759 }
@@ -793,17 +792,17 @@ main_notify_handler (void *cls, const struct GNUNET_MessageHeader *msg)
793 792
794 if (msg == NULL) 793 if (msg == NULL)
795 { 794 {
796 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 795 LOG (GNUNET_ERROR_TYPE_INFO,
797 _ 796 _
798 ("Client was disconnected from core service, trying to reconnect.\n")); 797 ("Client was disconnected from core service, trying to reconnect.\n"));
799 reconnect_later (h); 798 reconnect_later (h);
800 return; 799 return;
801 } 800 }
802 msize = ntohs (msg->size); 801 msize = ntohs (msg->size);
803#if DEBUG_CORE > 2 802#if DEBUG_CORE > 2
804 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 803 LOG (GNUNET_ERROR_TYPE_DEBUG,
805 "Processing message of type %u and size %u from core service\n", 804 "Processing message of type %u and size %u from core service\n",
806 ntohs (msg->type), msize); 805 ntohs (msg->type), msize);
807#endif 806#endif
808 switch (ntohs (msg->type)) 807 switch (ntohs (msg->type))
809 { 808 {
@@ -829,17 +828,16 @@ main_notify_handler (void *cls, const struct GNUNET_MessageHeader *msg)
829 /* mark so we don't call init on reconnect */ 828 /* mark so we don't call init on reconnect */
830 h->init = NULL; 829 h->init = NULL;
831#if DEBUG_CORE 830#if DEBUG_CORE
832 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 831 LOG (GNUNET_ERROR_TYPE_DEBUG, "Connected to core service of peer `%s'.\n",
833 "Connected to core service of peer `%s'.\n", 832 GNUNET_i2s (&h->me));
834 GNUNET_i2s (&h->me));
835#endif 833#endif
836 init (h->cls, h, &h->me); 834 init (h->cls, h, &h->me);
837 } 835 }
838 else 836 else
839 { 837 {
840#if DEBUG_CORE 838#if DEBUG_CORE
841 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 839 LOG (GNUNET_ERROR_TYPE_DEBUG,
842 "Successfully reconnected to core service.\n"); 840 "Successfully reconnected to core service.\n");
843#endif 841#endif
844 } 842 }
845 /* fake 'connect to self' */ 843 /* fake 'connect to self' */
@@ -875,9 +873,9 @@ main_notify_handler (void *cls, const struct GNUNET_MessageHeader *msg)
875 return; 873 return;
876 } 874 }
877#if DEBUG_CORE 875#if DEBUG_CORE
878 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 876 LOG (GNUNET_ERROR_TYPE_DEBUG,
879 "Received notification about connection from `%s'.\n", 877 "Received notification about connection from `%s'.\n",
880 GNUNET_i2s (&cnm->peer)); 878 GNUNET_i2s (&cnm->peer));
881#endif 879#endif
882 if (0 == memcmp (&h->me, &cnm->peer, sizeof (struct GNUNET_PeerIdentity))) 880 if (0 == memcmp (&h->me, &cnm->peer, sizeof (struct GNUNET_PeerIdentity)))
883 { 881 {
@@ -918,9 +916,9 @@ main_notify_handler (void *cls, const struct GNUNET_MessageHeader *msg)
918 } 916 }
919 GNUNET_break (0 == ntohl (dnm->reserved)); 917 GNUNET_break (0 == ntohl (dnm->reserved));
920#if DEBUG_CORE 918#if DEBUG_CORE
921 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 919 LOG (GNUNET_ERROR_TYPE_DEBUG,
922 "Received notification about disconnect from `%s'.\n", 920 "Received notification about disconnect from `%s'.\n",
923 GNUNET_i2s (&dnm->peer)); 921 GNUNET_i2s (&dnm->peer));
924#endif 922#endif
925 pr = GNUNET_CONTAINER_multihashmap_get (h->peers, &dnm->peer.hashPubKey); 923 pr = GNUNET_CONTAINER_multihashmap_get (h->peers, &dnm->peer.hashPubKey);
926 if (pr == NULL) 924 if (pr == NULL)
@@ -958,9 +956,9 @@ main_notify_handler (void *cls, const struct GNUNET_MessageHeader *msg)
958 } 956 }
959 em = (const struct GNUNET_MessageHeader *) &(&ntm->ats)[ats_count + 1]; 957 em = (const struct GNUNET_MessageHeader *) &(&ntm->ats)[ats_count + 1];
960#if DEBUG_CORE 958#if DEBUG_CORE
961 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 959 LOG (GNUNET_ERROR_TYPE_DEBUG,
962 "Received message of type %u and size %u from peer `%4s'\n", 960 "Received message of type %u and size %u from peer `%4s'\n",
963 ntohs (em->type), ntohs (em->size), GNUNET_i2s (&ntm->peer)); 961 ntohs (em->type), ntohs (em->size), GNUNET_i2s (&ntm->peer));
964#endif 962#endif
965 pr = GNUNET_CONTAINER_multihashmap_get (h->peers, &ntm->peer.hashPubKey); 963 pr = GNUNET_CONTAINER_multihashmap_get (h->peers, &ntm->peer.hashPubKey);
966 if (pr == NULL) 964 if (pr == NULL)
@@ -1034,9 +1032,9 @@ main_notify_handler (void *cls, const struct GNUNET_MessageHeader *msg)
1034 return; 1032 return;
1035 } 1033 }
1036#if DEBUG_CORE 1034#if DEBUG_CORE
1037 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1035 LOG (GNUNET_ERROR_TYPE_DEBUG,
1038 "Received notification about transmission to `%s'.\n", 1036 "Received notification about transmission to `%s'.\n",
1039 GNUNET_i2s (&ntm->peer)); 1037 GNUNET_i2s (&ntm->peer));
1040#endif 1038#endif
1041 if ((GNUNET_NO == h->outbound_hdr_only) && 1039 if ((GNUNET_NO == h->outbound_hdr_only) &&
1042 (msize != 1040 (msize !=
@@ -1070,9 +1068,9 @@ main_notify_handler (void *cls, const struct GNUNET_MessageHeader *msg)
1070 return; 1068 return;
1071 } 1069 }
1072#if DEBUG_CORE 1070#if DEBUG_CORE
1073 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1071 LOG (GNUNET_ERROR_TYPE_DEBUG,
1074 "Received notification about transmission readiness to `%s'.\n", 1072 "Received notification about transmission readiness to `%s'.\n",
1075 GNUNET_i2s (&smr->peer)); 1073 GNUNET_i2s (&smr->peer));
1076#endif 1074#endif
1077 if (pr->pending_head == NULL) 1075 if (pr->pending_head == NULL)
1078 { 1076 {
@@ -1124,8 +1122,8 @@ init_done_task (void *cls, int success)
1124 if (success == GNUNET_NO) 1122 if (success == GNUNET_NO)
1125 { 1123 {
1126#if DEBUG_CORE 1124#if DEBUG_CORE
1127 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1125 LOG (GNUNET_ERROR_TYPE_DEBUG,
1128 "Failed to exchange INIT with core, retrying\n"); 1126 "Failed to exchange INIT with core, retrying\n");
1129#endif 1127#endif
1130 if (h->reconnect_task == GNUNET_SCHEDULER_NO_TASK) 1128 if (h->reconnect_task == GNUNET_SCHEDULER_NO_TASK)
1131 reconnect_later (h); 1129 reconnect_later (h);
@@ -1153,7 +1151,7 @@ reconnect (struct GNUNET_CORE_Handle *h)
1153 unsigned int hpos; 1151 unsigned int hpos;
1154 1152
1155#if DEBUG_CORE 1153#if DEBUG_CORE
1156 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Reconnecting to CORE service\n"); 1154 LOG (GNUNET_ERROR_TYPE_DEBUG, "Reconnecting to CORE service\n");
1157#endif 1155#endif
1158 GNUNET_assert (h->client == NULL); 1156 GNUNET_assert (h->client == NULL);
1159 GNUNET_assert (h->currently_down == GNUNET_YES); 1157 GNUNET_assert (h->currently_down == GNUNET_YES);
@@ -1256,7 +1254,7 @@ GNUNET_CORE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
1256 (GNUNET_SERVER_MAX_MESSAGE_SIZE - 1254 (GNUNET_SERVER_MAX_MESSAGE_SIZE -
1257 sizeof (struct InitMessage)) / sizeof (uint16_t)); 1255 sizeof (struct InitMessage)) / sizeof (uint16_t));
1258#if DEBUG_CORE 1256#if DEBUG_CORE
1259 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting to CORE service\n"); 1257 LOG (GNUNET_ERROR_TYPE_DEBUG, "Connecting to CORE service\n");
1260#endif 1258#endif
1261 reconnect (h); 1259 reconnect (h);
1262 return h; 1260 return h;
@@ -1276,7 +1274,7 @@ GNUNET_CORE_disconnect (struct GNUNET_CORE_Handle *handle)
1276 struct ControlMessage *cm; 1274 struct ControlMessage *cm;
1277 1275
1278#if DEBUG_CORE 1276#if DEBUG_CORE
1279 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from CORE service\n"); 1277 LOG (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from CORE service\n");
1280#endif 1278#endif
1281 if (handle->cth != NULL) 1279 if (handle->cth != NULL)
1282 { 1280 {
@@ -1368,9 +1366,9 @@ GNUNET_CORE_notify_transmit_ready (struct GNUNET_CORE_Handle *handle, int cork,
1368 if (NULL == pr) 1366 if (NULL == pr)
1369 { 1367 {
1370 /* attempt to send to peer that is not connected */ 1368 /* attempt to send to peer that is not connected */
1371 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1369 LOG (GNUNET_ERROR_TYPE_WARNING,
1372 "Attempting to send to peer `%s' from peer `%s', but not connected!\n", 1370 "Attempting to send to peer `%s' from peer `%s', but not connected!\n",
1373 GNUNET_i2s (target), GNUNET_h2s (&handle->me.hashPubKey)); 1371 GNUNET_i2s (target), GNUNET_h2s (&handle->me.hashPubKey));
1374 GNUNET_break (0); 1372 GNUNET_break (0);
1375 return NULL; 1373 return NULL;
1376 } 1374 }
@@ -1403,16 +1401,16 @@ GNUNET_CORE_notify_transmit_ready (struct GNUNET_CORE_Handle *handle, int cork,
1403 GNUNET_break (pr->queue_size == 1); 1401 GNUNET_break (pr->queue_size == 1);
1404 GNUNET_free (th); 1402 GNUNET_free (th);
1405#if DEBUG_CORE 1403#if DEBUG_CORE
1406 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1404 LOG (GNUNET_ERROR_TYPE_DEBUG,
1407 "Dropping transmission request: cannot drop queue head and limit is one\n"); 1405 "Dropping transmission request: cannot drop queue head and limit is one\n");
1408#endif 1406#endif
1409 return NULL; 1407 return NULL;
1410 } 1408 }
1411 if (priority <= minp->priority) 1409 if (priority <= minp->priority)
1412 { 1410 {
1413#if DEBUG_CORE 1411#if DEBUG_CORE
1414 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1412 LOG (GNUNET_ERROR_TYPE_DEBUG,
1415 "Dropping transmission request: priority too low\n"); 1413 "Dropping transmission request: priority too low\n");
1416#endif 1414#endif
1417 GNUNET_free (th); 1415 GNUNET_free (th);
1418 return NULL; /* priority too low */ 1416 return NULL; /* priority too low */
@@ -1445,7 +1443,7 @@ GNUNET_CORE_notify_transmit_ready (struct GNUNET_CORE_Handle *handle, int cork,
1445 pr->queue_size++; 1443 pr->queue_size++;
1446 /* was the request queue previously empty? */ 1444 /* was the request queue previously empty? */
1447#if DEBUG_CORE 1445#if DEBUG_CORE
1448 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Transmission request added to queue\n"); 1446 LOG (GNUNET_ERROR_TYPE_DEBUG, "Transmission request added to queue\n");
1449#endif 1447#endif
1450 if ((pr->pending_head == th) && (pr->ntr_task == GNUNET_SCHEDULER_NO_TASK) && 1448 if ((pr->pending_head == th) && (pr->ntr_task == GNUNET_SCHEDULER_NO_TASK) &&
1451 (pr->next == NULL) && (pr->prev == NULL) && 1449 (pr->next == NULL) && (pr->prev == NULL) &&