diff options
author | Bart Polot <bart@net.in.tum.de> | 2013-03-06 11:46:49 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2013-03-06 11:46:49 +0000 |
commit | 9121a9b0b7ed56f9e12fe8a457ce091f37a13ffb (patch) | |
tree | e9569fe3f6b76b39e403c33d1cbd41279235c821 | |
parent | fca2ed8b3dc04106953333fef4fd5a2541f1947f (diff) | |
download | gnunet-9121a9b0b7ed56f9e12fe8a457ce091f37a13ffb.tar.gz gnunet-9121a9b0b7ed56f9e12fe8a457ce091f37a13ffb.zip |
- dont #define debug output, use getenv
-rw-r--r-- | src/dht/gnunet-service-dht_neighbours.c | 47 |
1 files changed, 23 insertions, 24 deletions
diff --git a/src/dht/gnunet-service-dht_neighbours.c b/src/dht/gnunet-service-dht_neighbours.c index 01fc4c431..b02025517 100644 --- a/src/dht/gnunet-service-dht_neighbours.c +++ b/src/dht/gnunet-service-dht_neighbours.c | |||
@@ -49,6 +49,9 @@ | |||
49 | #include <fenv.h> | 49 | #include <fenv.h> |
50 | #include "dht.h" | 50 | #include "dht.h" |
51 | 51 | ||
52 | |||
53 | #define LOG_TRAFFIC(kind,...) GNUNET_log_from (kind, "dht-traffic",__VA_ARGS__) | ||
54 | |||
52 | /** | 55 | /** |
53 | * How many buckets will we allow total. | 56 | * How many buckets will we allow total. |
54 | */ | 57 | */ |
@@ -95,12 +98,6 @@ | |||
95 | #define GET_TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 2) | 98 | #define GET_TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 2) |
96 | 99 | ||
97 | /** | 100 | /** |
98 | * Should routing details be logged to stderr (for debugging)? | ||
99 | */ | ||
100 | #define LOG_ROUTE_DETAILS_STDERR GNUNET_NO | ||
101 | |||
102 | |||
103 | /** | ||
104 | * Hello address expiration | 101 | * Hello address expiration |
105 | */ | 102 | */ |
106 | extern struct GNUNET_TIME_Relative hello_expiration; | 103 | extern struct GNUNET_TIME_Relative hello_expiration; |
@@ -382,6 +379,10 @@ struct PeerBucket | |||
382 | unsigned int peers_size; | 379 | unsigned int peers_size; |
383 | }; | 380 | }; |
384 | 381 | ||
382 | /** | ||
383 | * Should routing details be logged to stderr (for debugging)? | ||
384 | */ | ||
385 | static int log_route_details_stderr; | ||
385 | 386 | ||
386 | /** | 387 | /** |
387 | * The lowest currently used bucket, initially 0 (for 0-bits matching bucket). | 388 | * The lowest currently used bucket, initially 0 (for 0-bits matching bucket). |
@@ -1600,15 +1601,14 @@ handle_dht_p2p_put (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
1600 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "PUT for `%s' from %s\n", | 1601 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "PUT for `%s' from %s\n", |
1601 | GNUNET_h2s (&put->key), GNUNET_i2s (peer)); | 1602 | GNUNET_h2s (&put->key), GNUNET_i2s (peer)); |
1602 | 1603 | ||
1603 | if (LOG_ROUTE_DETAILS_STDERR) | 1604 | if (GNUNET_YES == log_route_details_stderr) |
1604 | { | 1605 | { |
1605 | char *tmp; | 1606 | char *tmp; |
1606 | 1607 | ||
1607 | tmp = GNUNET_strdup (GNUNET_i2s (&my_identity)); | 1608 | tmp = GNUNET_strdup (GNUNET_i2s (&my_identity)); |
1608 | fprintf (stderr, "XDHT PUT %s: %s(%u)<-%s\n", | 1609 | LOG_TRAFFIC (GNUNET_ERROR_TYPE_ERROR, "XDHT PUT %s: %s(%u)<-%s\n", |
1609 | GNUNET_h2s (&put->key), tmp, getpid (), | 1610 | GNUNET_h2s (&put->key), tmp, getpid (), GNUNET_i2s (peer)); |
1610 | GNUNET_i2s (peer)); | 1611 | GNUNET_free (tmp); |
1611 | GNUNET_free (tmp); | ||
1612 | } | 1612 | } |
1613 | 1613 | ||
1614 | 1614 | ||
@@ -1860,14 +1860,13 @@ handle_dht_p2p_get (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
1860 | 1, GNUNET_NO); | 1860 | 1, GNUNET_NO); |
1861 | } | 1861 | } |
1862 | 1862 | ||
1863 | if (LOG_ROUTE_DETAILS_STDERR) | 1863 | if (GNUNET_YES == log_route_details_stderr) |
1864 | { | 1864 | { |
1865 | char *tmp; | 1865 | char *tmp; |
1866 | 1866 | ||
1867 | tmp = GNUNET_strdup (GNUNET_i2s (&my_identity)); | 1867 | tmp = GNUNET_strdup (GNUNET_i2s (&my_identity)); |
1868 | fprintf (stderr, "XDHT GET %s: %s(%u)<-%s\n", | 1868 | LOG_TRAFFIC (GNUNET_ERROR_TYPE_DEBUG, "XDHT GET %s: %s(%u)<-%s\n", |
1869 | GNUNET_h2s (&get->key), tmp, getpid(), | 1869 | GNUNET_h2s (&get->key), tmp, getpid(), GNUNET_i2s (peer)); |
1870 | GNUNET_i2s (peer)); | ||
1871 | GNUNET_free (tmp); | 1870 | GNUNET_free (tmp); |
1872 | } | 1871 | } |
1873 | 1872 | ||
@@ -1991,16 +1990,14 @@ handle_dht_p2p_result (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
1991 | } | 1990 | } |
1992 | 1991 | ||
1993 | 1992 | ||
1994 | if (LOG_ROUTE_DETAILS_STDERR) | 1993 | if (GNUNET_YES == log_route_details_stderr) |
1995 | { | 1994 | { |
1996 | char *tmp; | 1995 | char *tmp; |
1997 | 1996 | ||
1998 | tmp = GNUNET_strdup (GNUNET_i2s (&my_identity)); | 1997 | tmp = GNUNET_strdup (GNUNET_i2s (&my_identity)); |
1999 | fprintf (stderr, | 1998 | LOG_TRAFFIC (GNUNET_ERROR_TYPE_DEBUG, "XDHT RESULT %s: %s(%u)<-%s\n", |
2000 | "XDHT RESULT %s: %s(%u)<-%s\n", | 1999 | GNUNET_h2s (&prm->key), tmp, getpid(), GNUNET_i2s (peer)); |
2001 | GNUNET_h2s (&prm->key), tmp, | 2000 | GNUNET_free (tmp); |
2002 | getpid(), GNUNET_i2s (peer)); | ||
2003 | GNUNET_free (tmp); | ||
2004 | } | 2001 | } |
2005 | 2002 | ||
2006 | /* append 'peer' to 'get_path' */ | 2003 | /* append 'peer' to 'get_path' */ |
@@ -2057,6 +2054,8 @@ GDS_NEIGHBOURS_init () | |||
2057 | GNUNET_CONFIGURATION_get_value_number (GDS_cfg, "DHT", "bucket_size", | 2054 | GNUNET_CONFIGURATION_get_value_number (GDS_cfg, "DHT", "bucket_size", |
2058 | &temp_config_num)) | 2055 | &temp_config_num)) |
2059 | bucket_size = (unsigned int) temp_config_num; | 2056 | bucket_size = (unsigned int) temp_config_num; |
2057 | log_route_details_stderr = | ||
2058 | (NULL != getenv("GNUNET_DHT_ROUTE_DEBUG")) ? GNUNET_YES : GNUNET_NO; | ||
2060 | atsAPI = GNUNET_ATS_performance_init (GDS_cfg, NULL, NULL); | 2059 | atsAPI = GNUNET_ATS_performance_init (GDS_cfg, NULL, NULL); |
2061 | coreAPI = | 2060 | coreAPI = |
2062 | GNUNET_CORE_connect (GDS_cfg, NULL, &core_init, &handle_core_connect, | 2061 | GNUNET_CORE_connect (GDS_cfg, NULL, &core_init, &handle_core_connect, |