aboutsummaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-05-06 01:12:57 +0000
committerChristian Grothoff <christian@grothoff.org>2012-05-06 01:12:57 +0000
commit9fac6b6eefdc9144053f736fd388cb2199a97046 (patch)
tree82740a981b7f6ae973d915aa77797acd9db668b2 /src/util
parent23d8d343d5c70481ecf78ec4fafc698907f3e8a9 (diff)
downloadgnunet-9fac6b6eefdc9144053f736fd388cb2199a97046.tar.gz
gnunet-9fac6b6eefdc9144053f736fd388cb2199a97046.zip
-removing legacy ifdefs, fixing log statements
Diffstat (limited to 'src/util')
-rw-r--r--src/util/container_heap.c14
-rw-r--r--src/util/gnunet-service-resolver.c8
-rw-r--r--src/util/resolver.h2
-rw-r--r--src/util/resolver_api.c26
-rw-r--r--src/util/test_configuration.c7
5 files changed, 15 insertions, 42 deletions
diff --git a/src/util/container_heap.c b/src/util/container_heap.c
index c34e220ce..b9cab1e9c 100644
--- a/src/util/container_heap.c
+++ b/src/util/container_heap.c
@@ -30,7 +30,7 @@
30 30
31#define LOG(kind,...) GNUNET_log_from (kind, "util", __VA_ARGS__) 31#define LOG(kind,...) GNUNET_log_from (kind, "util", __VA_ARGS__)
32 32
33#define DEBUG 0 33#define EXTRA_CHECKS 0
34 34
35/** 35/**
36 * Node in the heap. 36 * Node in the heap.
@@ -104,7 +104,7 @@ struct GNUNET_CONTAINER_Heap
104}; 104};
105 105
106 106
107#if DEBUG 107#if EXTRA_CHECKS
108/** 108/**
109 * Check if internal invariants hold for the given node. 109 * Check if internal invariants hold for the given node.
110 * 110 *
@@ -401,7 +401,7 @@ GNUNET_CONTAINER_heap_remove_root (struct GNUNET_CONTAINER_Heap *heap)
401 insert_node (heap, heap->root, root->right_child); 401 insert_node (heap, heap->root, root->right_child);
402 } 402 }
403 GNUNET_free (root); 403 GNUNET_free (root);
404#if DEBUG 404#if EXTRA_CHECKS
405 GNUNET_assert (((heap->size == 0) && (heap->root == NULL)) || 405 GNUNET_assert (((heap->size == 0) && (heap->root == NULL)) ||
406 (heap->size == heap->root->tree_size + 1)); 406 (heap->size == heap->root->tree_size + 1));
407 CHECK (heap->root); 407 CHECK (heap->root);
@@ -502,7 +502,7 @@ GNUNET_CONTAINER_heap_remove_node (struct GNUNET_CONTAINER_HeapNode *node)
502 if (heap->walk_pos == node) 502 if (heap->walk_pos == node)
503 heap->walk_pos = NULL; 503 heap->walk_pos = NULL;
504 GNUNET_free (node); 504 GNUNET_free (node);
505#if DEBUG 505#if EXTRA_CHECKS
506 CHECK (heap->root); 506 CHECK (heap->root);
507 GNUNET_assert (((heap->size == 0) && (heap->root == NULL)) || 507 GNUNET_assert (((heap->size == 0) && (heap->root == NULL)) ||
508 (heap->size == heap->root->tree_size + 1)); 508 (heap->size == heap->root->tree_size + 1));
@@ -523,13 +523,13 @@ GNUNET_CONTAINER_heap_update_cost (struct GNUNET_CONTAINER_Heap *heap,
523 struct GNUNET_CONTAINER_HeapNode *node, 523 struct GNUNET_CONTAINER_HeapNode *node,
524 GNUNET_CONTAINER_HeapCostType new_cost) 524 GNUNET_CONTAINER_HeapCostType new_cost)
525{ 525{
526#if DEBUG 526#if EXTRA_CHECKS
527 GNUNET_assert (((heap->size == 0) && (heap->root == NULL)) || 527 GNUNET_assert (((heap->size == 0) && (heap->root == NULL)) ||
528 (heap->size == heap->root->tree_size + 1)); 528 (heap->size == heap->root->tree_size + 1));
529 CHECK (heap->root); 529 CHECK (heap->root);
530#endif 530#endif
531 remove_node (node); 531 remove_node (node);
532#if DEBUG 532#if EXTRA_CHECKS
533 CHECK (heap->root); 533 CHECK (heap->root);
534 GNUNET_assert (((heap->size == 1) && (heap->root == NULL)) || 534 GNUNET_assert (((heap->size == 1) && (heap->root == NULL)) ||
535 (heap->size == heap->root->tree_size + 2)); 535 (heap->size == heap->root->tree_size + 2));
@@ -539,7 +539,7 @@ GNUNET_CONTAINER_heap_update_cost (struct GNUNET_CONTAINER_Heap *heap,
539 heap->root = node; 539 heap->root = node;
540 else 540 else
541 insert_node (heap, heap->root, node); 541 insert_node (heap, heap->root, node);
542#if DEBUG 542#if EXTRA_CHECKS
543 CHECK (heap->root); 543 CHECK (heap->root);
544 GNUNET_assert (((heap->size == 0) && (heap->root == NULL)) || 544 GNUNET_assert (((heap->size == 0) && (heap->root == NULL)) ||
545 (heap->size == heap->root->tree_size + 1)); 545 (heap->size == heap->root->tree_size + 1));
diff --git a/src/util/gnunet-service-resolver.c b/src/util/gnunet-service-resolver.c
index f20666a38..97eba6d11 100644
--- a/src/util/gnunet-service-resolver.c
+++ b/src/util/gnunet-service-resolver.c
@@ -490,10 +490,8 @@ handle_get (void *cls, struct GNUNET_SERVER_Client *client,
490 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); 490 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
491 return; 491 return;
492 } 492 }
493#if DEBUG_RESOLVER 493 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Resolver asked to look up `%s'.\n",
494 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Resolver asked to look up `%s'.\n"),
495 hostname); 494 hostname);
496#endif
497 get_ip_from_hostname (client, hostname, af); 495 get_ip_from_hostname (client, hostname, af);
498 return; 496 return;
499 } 497 }
@@ -521,15 +519,13 @@ handle_get (void *cls, struct GNUNET_SERVER_Client *client,
521 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); 519 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
522 return; 520 return;
523 } 521 }
524#if DEBUG_RESOLVER
525 { 522 {
526 char buf[INET6_ADDRSTRLEN]; 523 char buf[INET6_ADDRSTRLEN];
527 524
528 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 525 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
529 _("Resolver asked to look up IP address `%s'.\n"), 526 "Resolver asked to look up IP address `%s'.\n",
530 inet_ntop (af, ip, buf, sizeof (buf))); 527 inet_ntop (af, ip, buf, sizeof (buf)));
531 } 528 }
532#endif
533 get_ip_as_string (client, af, ip); 529 get_ip_as_string (client, af, ip);
534} 530}
535 531
diff --git a/src/util/resolver.h b/src/util/resolver.h
index 2c0de9910..b77c19926 100644
--- a/src/util/resolver.h
+++ b/src/util/resolver.h
@@ -27,8 +27,6 @@
27 27
28#include "gnunet_common.h" 28#include "gnunet_common.h"
29 29
30#define DEBUG_RESOLVER GNUNET_EXTRA_LOGGING
31
32GNUNET_NETWORK_STRUCT_BEGIN 30GNUNET_NETWORK_STRUCT_BEGIN
33 31
34/** 32/**
diff --git a/src/util/resolver_api.c b/src/util/resolver_api.c
index ab0574efa..87b76f12d 100644
--- a/src/util/resolver_api.c
+++ b/src/util/resolver_api.c
@@ -250,9 +250,7 @@ GNUNET_RESOLVER_disconnect ()
250 GNUNET_assert (NULL == req_tail); 250 GNUNET_assert (NULL == req_tail);
251 if (NULL != client) 251 if (NULL != client)
252 { 252 {
253#if DEBUG_RESOLVER
254 LOG (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from DNS service\n"); 253 LOG (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from DNS service\n");
255#endif
256 GNUNET_CLIENT_disconnect (client); 254 GNUNET_CLIENT_disconnect (client);
257 client = NULL; 255 client = NULL;
258 } 256 }
@@ -339,9 +337,7 @@ handle_response (void *cls, const struct GNUNET_MessageHeader *msg)
339 struct GNUNET_RESOLVER_RequestHandle *rh = cls; 337 struct GNUNET_RESOLVER_RequestHandle *rh = cls;
340 uint16_t size; 338 uint16_t size;
341 339
342#if DEBUG_RESOLVER
343 LOG (GNUNET_ERROR_TYPE_DEBUG, "Receiving response from DNS service\n"); 340 LOG (GNUNET_ERROR_TYPE_DEBUG, "Receiving response from DNS service\n");
344#endif
345 if (msg == NULL) 341 if (msg == NULL)
346 { 342 {
347 char buf[INET6_ADDRSTRLEN]; 343 char buf[INET6_ADDRSTRLEN];
@@ -422,10 +418,8 @@ handle_response (void *cls, const struct GNUNET_MessageHeader *msg)
422 reconnect (); 418 reconnect ();
423 return; 419 return;
424 } 420 }
425#if DEBUG_RESOLVER 421 LOG (GNUNET_ERROR_TYPE_DEBUG, "Resolver returns `%s' for IP `%s'.\n",
426 LOG (GNUNET_ERROR_TYPE_DEBUG, _("Resolver returns `%s' for IP `%s'.\n"),
427 hostname, GNUNET_a2s ((const void *) &rh[1], rh->data_len)); 422 hostname, GNUNET_a2s ((const void *) &rh[1], rh->data_len));
428#endif
429 if (rh->was_transmitted != GNUNET_SYSERR) 423 if (rh->was_transmitted != GNUNET_SYSERR)
430 rh->name_callback (rh->cls, hostname); 424 rh->name_callback (rh->cls, hostname);
431 rh->received_response = GNUNET_YES; 425 rh->received_response = GNUNET_YES;
@@ -633,10 +627,8 @@ process_requests ()
633 msg->direction = htonl (rh->direction); 627 msg->direction = htonl (rh->direction);
634 msg->af = htonl (rh->af); 628 msg->af = htonl (rh->af);
635 memcpy (&msg[1], &rh[1], rh->data_len); 629 memcpy (&msg[1], &rh[1], rh->data_len);
636#if DEBUG_RESOLVER
637 LOG (GNUNET_ERROR_TYPE_DEBUG, 630 LOG (GNUNET_ERROR_TYPE_DEBUG,
638 "Transmitting DNS resolution request to DNS service\n"); 631 "Transmitting DNS resolution request to DNS service\n");
639#endif
640 if (GNUNET_OK != 632 if (GNUNET_OK !=
641 GNUNET_CLIENT_transmit_and_get_response (client, &msg->header, 633 GNUNET_CLIENT_transmit_and_get_response (client, &msg->header,
642 GNUNET_TIME_absolute_get_remaining 634 GNUNET_TIME_absolute_get_remaining
@@ -666,9 +658,7 @@ reconnect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
666 return; /* no work pending */ 658 return; /* no work pending */
667 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) 659 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
668 return; 660 return;
669#if DEBUG_RESOLVER
670 LOG (GNUNET_ERROR_TYPE_DEBUG, "Trying to connect to DNS service\n"); 661 LOG (GNUNET_ERROR_TYPE_DEBUG, "Trying to connect to DNS service\n");
671#endif
672 client = GNUNET_CLIENT_connect ("resolver", resolver_cfg); 662 client = GNUNET_CLIENT_connect ("resolver", resolver_cfg);
673 if (NULL == client) 663 if (NULL == client)
674 { 664 {
@@ -712,11 +702,9 @@ reconnect ()
712 break; 702 break;
713 } 703 }
714 } 704 }
715#if DEBUG_RESOLVER
716 LOG (GNUNET_ERROR_TYPE_DEBUG, 705 LOG (GNUNET_ERROR_TYPE_DEBUG,
717 "Will try to connect to DNS service in %llu ms\n", 706 "Will try to connect to DNS service in %llu ms\n",
718 (unsigned long long) backoff.rel_value); 707 (unsigned long long) backoff.rel_value);
719#endif
720 GNUNET_assert (NULL != resolver_cfg); 708 GNUNET_assert (NULL != resolver_cfg);
721 r_task = GNUNET_SCHEDULER_add_delayed (backoff, &reconnect_task, NULL); 709 r_task = GNUNET_SCHEDULER_add_delayed (backoff, &reconnect_task, NULL);
722 backoff = GNUNET_TIME_relative_multiply (backoff, 2); 710 backoff = GNUNET_TIME_relative_multiply (backoff, 2);
@@ -803,9 +791,7 @@ numeric_reverse (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
803 char *result; 791 char *result;
804 792
805 result = no_resolve (rh->af, &rh[1], rh->data_len); 793 result = no_resolve (rh->af, &rh[1], rh->data_len);
806#if DEBUG_RESOLVER 794 LOG (GNUNET_ERROR_TYPE_DEBUG, "Resolver returns `%s'.\n", result);
807 LOG (GNUNET_ERROR_TYPE_DEBUG, _("Resolver returns `%s'.\n"), result);
808#endif
809 if (result != NULL) 795 if (result != NULL)
810 { 796 {
811 rh->name_callback (rh->cls, result); 797 rh->name_callback (rh->cls, result);
@@ -897,9 +883,7 @@ GNUNET_RESOLVER_local_fqdn_get ()
897 "gethostname"); 883 "gethostname");
898 return NULL; 884 return NULL;
899 } 885 }
900#if DEBUG_RESOLVER 886 LOG (GNUNET_ERROR_TYPE_DEBUG, "Resolving our FQDN `%s'\n", hostname);
901 LOG (GNUNET_ERROR_TYPE_DEBUG, _("Resolving our FQDN `%s'\n"), hostname);
902#endif
903 host = gethostbyname (hostname); 887 host = gethostbyname (hostname);
904 if (NULL == host) 888 if (NULL == host)
905 { 889 {
@@ -934,9 +918,7 @@ GNUNET_RESOLVER_hostname_resolve (int af,
934 "gethostname"); 918 "gethostname");
935 return NULL; 919 return NULL;
936 } 920 }
937#if DEBUG_RESOLVER 921 LOG (GNUNET_ERROR_TYPE_DEBUG, "Resolving our hostname `%s'\n", hostname);
938 LOG (GNUNET_ERROR_TYPE_DEBUG, _("Resolving our hostname `%s'\n"), hostname);
939#endif
940 return GNUNET_RESOLVER_ip_get (hostname, af, timeout, callback, cls); 922 return GNUNET_RESOLVER_ip_get (hostname, af, timeout, callback, cls);
941} 923}
942 924
diff --git a/src/util/test_configuration.c b/src/util/test_configuration.c
index b1a446f86..1242a5c8d 100644
--- a/src/util/test_configuration.c
+++ b/src/util/test_configuration.c
@@ -28,7 +28,6 @@
28#include "gnunet_configuration_lib.h" 28#include "gnunet_configuration_lib.h"
29#include "gnunet_disk_lib.h" 29#include "gnunet_disk_lib.h"
30 30
31#define DEBUG GNUNET_EXTRA_LOGGING
32 31
33/* Test Configuration Diffs Options */ 32/* Test Configuration Diffs Options */
34enum 33enum
@@ -40,10 +39,8 @@ enum
40 ADD_NEW_ENTRY, 39 ADD_NEW_ENTRY,
41 REMOVE_SECTION, 40 REMOVE_SECTION,
42 REMOVE_ENTRY, 41 REMOVE_ENTRY,
43 COMPARE 42 COMPARE,
44#if DEBUG 43 PRINT
45 , PRINT
46#endif
47}; 44};
48 45
49static struct GNUNET_CONFIGURATION_Handle *cfg; 46static struct GNUNET_CONFIGURATION_Handle *cfg;