diff options
author | Christian Grothoff <christian@grothoff.org> | 2010-05-25 15:53:30 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2010-05-25 15:53:30 +0000 |
commit | 27b1cf6f88f5e8ab34338083f1a4cc5e4ada7823 (patch) | |
tree | d73a61f278ad5b424df70cbabb1c837a100bdd4f /src/peerinfo | |
parent | 7e15432358bcfd05508c3eab9a47b14e8301b199 (diff) | |
download | gnunet-27b1cf6f88f5e8ab34338083f1a4cc5e4ada7823.tar.gz gnunet-27b1cf6f88f5e8ab34338083f1a4cc5e4ada7823.zip |
nicer logging
Diffstat (limited to 'src/peerinfo')
-rw-r--r-- | src/peerinfo/peerinfo_api.c | 55 |
1 files changed, 39 insertions, 16 deletions
diff --git a/src/peerinfo/peerinfo_api.c b/src/peerinfo/peerinfo_api.c index 5def415e9..7b89c18b2 100644 --- a/src/peerinfo/peerinfo_api.c +++ b/src/peerinfo/peerinfo_api.c | |||
@@ -226,12 +226,9 @@ do_transmit (void *cls, size_t size, void *buf) | |||
226 | h->th = NULL; | 226 | h->th = NULL; |
227 | if (buf == NULL) | 227 | if (buf == NULL) |
228 | { | 228 | { |
229 | #if DEBUG_PEERINFO | 229 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
230 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 230 | _("Failed to transmit message to `%s' service.\n"), |
231 | _ | 231 | "PEERINFO"); |
232 | ("Failed to transmit message of type %u to `%s' service.\n"), | ||
233 | ntohs (msg->type), "peerinfo"); | ||
234 | #endif | ||
235 | if (tqe != NULL) | 232 | if (tqe != NULL) |
236 | GNUNET_CONTAINER_DLL_remove (h->tq_head, | 233 | GNUNET_CONTAINER_DLL_remove (h->tq_head, |
237 | h->tq_tail, | 234 | h->tq_tail, |
@@ -249,7 +246,13 @@ do_transmit (void *cls, size_t size, void *buf) | |||
249 | ret = tqe->size; | 246 | ret = tqe->size; |
250 | GNUNET_assert (size >= ret); | 247 | GNUNET_assert (size >= ret); |
251 | memcpy (buf, &tqe[1], ret); | 248 | memcpy (buf, &tqe[1], ret); |
252 | GNUNET_CONTAINER_DLL_remove (h->tq_head, | 249 | #if DEBUG_PEERINFO |
250 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
251 | "Transmitting request of size %u to `%s' service.\n", | ||
252 | ret, | ||
253 | "PEERINFO"); | ||
254 | #endif | ||
255 | GNUNET_CONTAINER_DLL_remove (h->tq_head, | ||
253 | h->tq_tail, | 256 | h->tq_tail, |
254 | tqe); | 257 | tqe); |
255 | if (tqe->cont != NULL) | 258 | if (tqe->cont != NULL) |
@@ -387,7 +390,7 @@ peerinfo_handler (void *cls, const struct GNUNET_MessageHeader *msg) | |||
387 | { | 390 | { |
388 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 391 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
389 | _("Failed to receive response from `%s' service.\n"), | 392 | _("Failed to receive response from `%s' service.\n"), |
390 | "peerinfo"); | 393 | "PEERINFO"); |
391 | reconnect (ic->h); | 394 | reconnect (ic->h); |
392 | trigger_transmit (ic->h); | 395 | trigger_transmit (ic->h); |
393 | if (ic->timeout_task != GNUNET_SCHEDULER_NO_TASK) | 396 | if (ic->timeout_task != GNUNET_SCHEDULER_NO_TASK) |
@@ -402,7 +405,8 @@ peerinfo_handler (void *cls, const struct GNUNET_MessageHeader *msg) | |||
402 | { | 405 | { |
403 | #if DEBUG_PEERINFO | 406 | #if DEBUG_PEERINFO |
404 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 407 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
405 | "Received end of list of peers from peerinfo database\n"); | 408 | "Received end of list of peers from `%s' service\n", |
409 | "PEERINFO"); | ||
406 | #endif | 410 | #endif |
407 | trigger_transmit (ic->h); | 411 | trigger_transmit (ic->h); |
408 | if (ic->timeout_task != GNUNET_SCHEDULER_NO_TASK) | 412 | if (ic->timeout_task != GNUNET_SCHEDULER_NO_TASK) |
@@ -449,10 +453,11 @@ peerinfo_handler (void *cls, const struct GNUNET_MessageHeader *msg) | |||
449 | } | 453 | } |
450 | #if DEBUG_PEERINFO | 454 | #if DEBUG_PEERINFO |
451 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 455 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
452 | "Received %u bytes of `%s' information about peer `%s' from PEERINFO database\n", | 456 | "Received %u bytes of `%s' information about peer `%s' from `%s' service\n", |
453 | (hello == NULL) ? 0 : (unsigned int) GNUNET_HELLO_size (hello), | 457 | (hello == NULL) ? 0 : (unsigned int) GNUNET_HELLO_size (hello), |
454 | "HELLO", | 458 | "HELLO", |
455 | GNUNET_i2s (&im->peer)); | 459 | GNUNET_i2s (&im->peer), |
460 | "PEERINFO"); | ||
456 | #endif | 461 | #endif |
457 | ic->h->in_receive = GNUNET_YES; | 462 | ic->h->in_receive = GNUNET_YES; |
458 | if (ic->callback != NULL) | 463 | if (ic->callback != NULL) |
@@ -479,6 +484,10 @@ iterator_start_receive (void *cls, | |||
479 | 484 | ||
480 | if (GNUNET_OK != transmit_success) | 485 | if (GNUNET_OK != transmit_success) |
481 | { | 486 | { |
487 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
488 | _("Failed to transmit iteration request to `%s' service (%d).\n"), | ||
489 | "PEERINFO", | ||
490 | transmit_success); | ||
482 | if (ic->timeout_task != GNUNET_SCHEDULER_NO_TASK) | 491 | if (ic->timeout_task != GNUNET_SCHEDULER_NO_TASK) |
483 | { | 492 | { |
484 | GNUNET_SCHEDULER_cancel (ic->h->sched, | 493 | GNUNET_SCHEDULER_cancel (ic->h->sched, |
@@ -487,10 +496,16 @@ iterator_start_receive (void *cls, | |||
487 | } | 496 | } |
488 | reconnect (ic->h); | 497 | reconnect (ic->h); |
489 | trigger_transmit (ic->h); | 498 | trigger_transmit (ic->h); |
490 | ic->callback (ic->callback_cls, NULL, NULL, 1); | 499 | if (ic->callback != NULL) |
500 | ic->callback (ic->callback_cls, NULL, NULL, 1); | ||
491 | GNUNET_free (ic); | 501 | GNUNET_free (ic); |
492 | return; | 502 | return; |
493 | } | 503 | } |
504 | #if DEBUG_PEERINFO | ||
505 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
506 | "Waiting for response from `%s' service.\n", | ||
507 | "PEERINFO"); | ||
508 | #endif | ||
494 | ic->h->in_receive = GNUNET_YES; | 509 | ic->h->in_receive = GNUNET_YES; |
495 | ic->in_receive = GNUNET_YES; | 510 | ic->in_receive = GNUNET_YES; |
496 | ic->tqe = NULL; | 511 | ic->tqe = NULL; |
@@ -513,6 +528,9 @@ signal_timeout (void *cls, | |||
513 | { | 528 | { |
514 | struct GNUNET_PEERINFO_IteratorContext *ic = cls; | 529 | struct GNUNET_PEERINFO_IteratorContext *ic = cls; |
515 | 530 | ||
531 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
532 | _("Timeout transmitting iteration request to `%s' service.\n"), | ||
533 | "PEERINFO"); | ||
516 | ic->timeout_task = GNUNET_SCHEDULER_NO_TASK; | 534 | ic->timeout_task = GNUNET_SCHEDULER_NO_TASK; |
517 | if (! ic->in_receive) | 535 | if (! ic->in_receive) |
518 | GNUNET_CONTAINER_DLL_remove (ic->h->tq_head, | 536 | GNUNET_CONTAINER_DLL_remove (ic->h->tq_head, |
@@ -562,12 +580,12 @@ GNUNET_PEERINFO_iterate (struct GNUNET_PEERINFO_Handle *h, | |||
562 | struct GNUNET_PEERINFO_IteratorContext *ic; | 580 | struct GNUNET_PEERINFO_IteratorContext *ic; |
563 | struct TransmissionQueueEntry *tqe; | 581 | struct TransmissionQueueEntry *tqe; |
564 | 582 | ||
565 | #if DEBUG_PEERINFO | ||
566 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
567 | "Requesting list of peers from peerinfo database\n"); | ||
568 | #endif | ||
569 | if (peer == NULL) | 583 | if (peer == NULL) |
570 | { | 584 | { |
585 | #if DEBUG_PEERINFO | ||
586 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
587 | "Requesting list of peers from PEERINFO service\n"); | ||
588 | #endif | ||
571 | tqe = GNUNET_malloc (sizeof (struct TransmissionQueueEntry) + | 589 | tqe = GNUNET_malloc (sizeof (struct TransmissionQueueEntry) + |
572 | sizeof (struct ListAllPeersMessage)); | 590 | sizeof (struct ListAllPeersMessage)); |
573 | tqe->size = sizeof (struct ListAllPeersMessage); | 591 | tqe->size = sizeof (struct ListAllPeersMessage); |
@@ -578,6 +596,11 @@ GNUNET_PEERINFO_iterate (struct GNUNET_PEERINFO_Handle *h, | |||
578 | } | 596 | } |
579 | else | 597 | else |
580 | { | 598 | { |
599 | #if DEBUG_PEERINFO | ||
600 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
601 | "Requesting information on peer `%4s' from PEERINFO service\n", | ||
602 | GNUNET_i2s (peer)); | ||
603 | #endif | ||
581 | tqe = GNUNET_malloc (sizeof (struct TransmissionQueueEntry) + | 604 | tqe = GNUNET_malloc (sizeof (struct TransmissionQueueEntry) + |
582 | sizeof (struct ListPeerMessage)); | 605 | sizeof (struct ListPeerMessage)); |
583 | tqe->size = sizeof (struct ListPeerMessage); | 606 | tqe->size = sizeof (struct ListPeerMessage); |