aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-06-23 22:24:50 +0000
committerChristian Grothoff <christian@grothoff.org>2012-06-23 22:24:50 +0000
commitd30c25b427875a16cc46cfd091f595f119e570bc (patch)
tree7e421bfae7f6efc16834816d30c81356d3c5b041 /src
parent8e6c69b6322f9d3f3f2a32040431a3b056302132 (diff)
downloadgnunet-d30c25b427875a16cc46cfd091f595f119e570bc.tar.gz
gnunet-d30c25b427875a16cc46cfd091f595f119e570bc.zip
-LRN: Change logskipping to use functions only:
Remember these weird "skip_log" functions in my gdb backtraces? I hope that this patch will get rid of them. Shouldn't affect existing uses of the API.
Diffstat (limited to 'src')
-rw-r--r--src/hostlist/test_gnunet_daemon_hostlist.c10
-rw-r--r--src/hostlist/test_gnunet_daemon_hostlist_learning.c10
-rw-r--r--src/include/gnunet_common.h15
-rw-r--r--src/stream/test_stream_api.c1
-rw-r--r--src/util/common_logging.c16
5 files changed, 23 insertions, 29 deletions
diff --git a/src/hostlist/test_gnunet_daemon_hostlist.c b/src/hostlist/test_gnunet_daemon_hostlist.c
index f13f86dfa..5f07ce415 100644
--- a/src/hostlist/test_gnunet_daemon_hostlist.c
+++ b/src/hostlist/test_gnunet_daemon_hostlist.c
@@ -27,10 +27,6 @@
27#include "gnunet_arm_service.h" 27#include "gnunet_arm_service.h"
28#include "gnunet_transport_service.h" 28#include "gnunet_transport_service.h"
29 29
30#define VERBOSE GNUNET_NO
31
32#define START_ARM GNUNET_YES
33
34 30
35/** 31/**
36 * How long until we give up on transmitting the message? 32 * How long until we give up on transmitting the message?
@@ -47,9 +43,7 @@ struct PeerContext
47 struct GNUNET_TRANSPORT_Handle *th; 43 struct GNUNET_TRANSPORT_Handle *th;
48 struct GNUNET_MessageHeader *hello; 44 struct GNUNET_MessageHeader *hello;
49 struct GNUNET_TRANSPORT_GetHelloHandle *ghh; 45 struct GNUNET_TRANSPORT_GetHelloHandle *ghh;
50#if START_ARM
51 struct GNUNET_OS_Process *arm_proc; 46 struct GNUNET_OS_Process *arm_proc;
52#endif
53}; 47};
54 48
55static struct PeerContext p1; 49static struct PeerContext p1;
@@ -138,12 +132,10 @@ static void
138setup_peer (struct PeerContext *p, const char *cfgname) 132setup_peer (struct PeerContext *p, const char *cfgname)
139{ 133{
140 p->cfg = GNUNET_CONFIGURATION_create (); 134 p->cfg = GNUNET_CONFIGURATION_create ();
141#if START_ARM
142 p->arm_proc = 135 p->arm_proc =
143 GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm", 136 GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
144 "gnunet-service-arm", 137 "gnunet-service-arm",
145 "-c", cfgname, NULL); 138 "-c", cfgname, NULL);
146#endif
147 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); 139 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
148 p->th = 140 p->th =
149 GNUNET_TRANSPORT_connect (p->cfg, NULL, p, NULL, &notify_connect, NULL); 141 GNUNET_TRANSPORT_connect (p->cfg, NULL, p, NULL, &notify_connect, NULL);
@@ -157,7 +149,6 @@ waitpid_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
157{ 149{
158 struct PeerContext *p = cls; 150 struct PeerContext *p = cls;
159 151
160#if START_ARM
161 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Killing ARM process.\n"); 152 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Killing ARM process.\n");
162 if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM)) 153 if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM))
163 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); 154 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
@@ -167,7 +158,6 @@ waitpid_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
167 GNUNET_OS_process_get_pid (p->arm_proc)); 158 GNUNET_OS_process_get_pid (p->arm_proc));
168 GNUNET_OS_process_destroy (p->arm_proc); 159 GNUNET_OS_process_destroy (p->arm_proc);
169 p->arm_proc = NULL; 160 p->arm_proc = NULL;
170#endif
171 GNUNET_CONFIGURATION_destroy (p->cfg); 161 GNUNET_CONFIGURATION_destroy (p->cfg);
172} 162}
173 163
diff --git a/src/hostlist/test_gnunet_daemon_hostlist_learning.c b/src/hostlist/test_gnunet_daemon_hostlist_learning.c
index b7d96687c..6f0ab4c9e 100644
--- a/src/hostlist/test_gnunet_daemon_hostlist_learning.c
+++ b/src/hostlist/test_gnunet_daemon_hostlist_learning.c
@@ -30,8 +30,6 @@
30#include "gnunet_resolver_service.h" 30#include "gnunet_resolver_service.h"
31#include "gnunet_statistics_service.h" 31#include "gnunet_statistics_service.h"
32 32
33#define START_ARM GNUNET_YES
34
35#define MAX_URL_LEN 1000 33#define MAX_URL_LEN 1000
36 34
37/** 35/**
@@ -49,9 +47,7 @@ struct PeerContext
49 struct GNUNET_MessageHeader *hello; 47 struct GNUNET_MessageHeader *hello;
50 struct GNUNET_CORE_Handle *core; 48 struct GNUNET_CORE_Handle *core;
51 struct GNUNET_STATISTICS_Handle *stats; 49 struct GNUNET_STATISTICS_Handle *stats;
52#if START_ARM
53 struct GNUNET_OS_Process *arm_proc; 50 struct GNUNET_OS_Process *arm_proc;
54#endif
55}; 51};
56 52
57static int timeout; 53static int timeout;
@@ -147,7 +143,6 @@ shutdown_testcase ()
147 GNUNET_CORE_disconnect (learn_peer.core); 143 GNUNET_CORE_disconnect (learn_peer.core);
148 learn_peer.core = NULL; 144 learn_peer.core = NULL;
149 } 145 }
150#if START_ARM
151 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 146 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
152 "Killing hostlist server ARM process.\n"); 147 "Killing hostlist server ARM process.\n");
153 if (0 != GNUNET_OS_process_kill (adv_peer.arm_proc, SIGTERM)) 148 if (0 != GNUNET_OS_process_kill (adv_peer.arm_proc, SIGTERM))
@@ -164,7 +159,6 @@ shutdown_testcase ()
164 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); 159 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
165 GNUNET_OS_process_destroy (learn_peer.arm_proc); 160 GNUNET_OS_process_destroy (learn_peer.arm_proc);
166 learn_peer.arm_proc = NULL; 161 learn_peer.arm_proc = NULL;
167#endif
168 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutdown complete....\n"); 162 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutdown complete....\n");
169} 163}
170 164
@@ -390,12 +384,10 @@ setup_learn_peer (struct PeerContext *p, const char *cfgname)
390 unsigned int result; 384 unsigned int result;
391 385
392 p->cfg = GNUNET_CONFIGURATION_create (); 386 p->cfg = GNUNET_CONFIGURATION_create ();
393#if START_ARM
394 p->arm_proc = 387 p->arm_proc =
395 GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm", 388 GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
396 "gnunet-service-arm", 389 "gnunet-service-arm",
397 "-c", cfgname, NULL); 390 "-c", cfgname, NULL);
398#endif
399 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); 391 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
400 if (GNUNET_OK == 392 if (GNUNET_OK ==
401 GNUNET_CONFIGURATION_get_value_string (p->cfg, "HOSTLIST", "HOSTLISTFILE", 393 GNUNET_CONFIGURATION_get_value_string (p->cfg, "HOSTLIST", "HOSTLISTFILE",
@@ -423,12 +415,10 @@ static void
423setup_adv_peer (struct PeerContext *p, const char *cfgname) 415setup_adv_peer (struct PeerContext *p, const char *cfgname)
424{ 416{
425 p->cfg = GNUNET_CONFIGURATION_create (); 417 p->cfg = GNUNET_CONFIGURATION_create ();
426#if START_ARM
427 p->arm_proc = 418 p->arm_proc =
428 GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm", 419 GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
429 "gnunet-service-arm", 420 "gnunet-service-arm",
430 "-c", cfgname, NULL); 421 "-c", cfgname, NULL);
431#endif
432 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); 422 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
433 p->stats = GNUNET_STATISTICS_create ("hostlist", p->cfg); 423 p->stats = GNUNET_STATISTICS_create ("hostlist", p->cfg);
434 GNUNET_assert (NULL != p->stats); 424 GNUNET_assert (NULL != p->stats);
diff --git a/src/include/gnunet_common.h b/src/include/gnunet_common.h
index 63a154390..e0a827911 100644
--- a/src/include/gnunet_common.h
+++ b/src/include/gnunet_common.h
@@ -284,9 +284,12 @@ typedef void (*GNUNET_Logger) (void *cls, enum GNUNET_ErrorType kind,
284 284
285 285
286/** 286/**
287 * Number of log calls to ignore. 287 * Get the number of log calls that are going to be skipped
288 *
289 * @return number of log calls to be ignored
288 */ 290 */
289extern unsigned int skip_log; 291int
292GNUNET_get_log_skip ();
290 293
291#if !defined(GNUNET_CULL_LOGGING) 294#if !defined(GNUNET_CULL_LOGGING)
292int 295int
@@ -344,7 +347,7 @@ GNUNET_log_from_nocheck (enum GNUNET_ErrorType kind, const char *comp,
344 if ((GNUNET_EXTRA_LOGGING > 0) || ((GNUNET_ERROR_TYPE_DEBUG & (kind)) == 0)) { \ 347 if ((GNUNET_EXTRA_LOGGING > 0) || ((GNUNET_ERROR_TYPE_DEBUG & (kind)) == 0)) { \
345 if (GN_UNLIKELY(log_call_enabled == -1))\ 348 if (GN_UNLIKELY(log_call_enabled == -1))\
346 log_call_enabled = GNUNET_get_log_call_status ((kind) & (~GNUNET_ERROR_TYPE_BULK), (comp), __FILE__, __FUNCTION__, log_line); \ 349 log_call_enabled = GNUNET_get_log_call_status ((kind) & (~GNUNET_ERROR_TYPE_BULK), (comp), __FILE__, __FUNCTION__, log_line); \
347 if (GN_UNLIKELY(skip_log > 0)) {skip_log--;}\ 350 if (GN_UNLIKELY(GNUNET_get_log_skip () > 0)) { GNUNET_log_skip (-1, GNUNET_NO); }\
348 else {\ 351 else {\
349 if (GN_UNLIKELY(log_call_enabled))\ 352 if (GN_UNLIKELY(log_call_enabled))\
350 GNUNET_log_from_nocheck ((kind), comp, __VA_ARGS__); \ 353 GNUNET_log_from_nocheck ((kind), comp, __VA_ARGS__); \
@@ -357,7 +360,7 @@ GNUNET_log_from_nocheck (enum GNUNET_ErrorType kind, const char *comp,
357 if ((GNUNET_EXTRA_LOGGING > 0) || ((GNUNET_ERROR_TYPE_DEBUG & (kind)) == 0)) { \ 360 if ((GNUNET_EXTRA_LOGGING > 0) || ((GNUNET_ERROR_TYPE_DEBUG & (kind)) == 0)) { \
358 if (GN_UNLIKELY(log_call_enabled == -1))\ 361 if (GN_UNLIKELY(log_call_enabled == -1))\
359 log_call_enabled = GNUNET_get_log_call_status ((kind) & (~GNUNET_ERROR_TYPE_BULK), NULL, __FILE__, __FUNCTION__, log_line);\ 362 log_call_enabled = GNUNET_get_log_call_status ((kind) & (~GNUNET_ERROR_TYPE_BULK), NULL, __FILE__, __FUNCTION__, log_line);\
360 if (GN_UNLIKELY(skip_log > 0)) {skip_log--;}\ 363 if (GN_UNLIKELY(GNUNET_get_log_skip () > 0)) { GNUNET_log_skip (-1, GNUNET_NO); }\
361 else {\ 364 else {\
362 if (GN_UNLIKELY(log_call_enabled))\ 365 if (GN_UNLIKELY(log_call_enabled))\
363 GNUNET_log_nocheck ((kind), __VA_ARGS__); \ 366 GNUNET_log_nocheck ((kind), __VA_ARGS__); \
@@ -379,11 +382,11 @@ GNUNET_abort (void) GNUNET_NORETURN;
379/** 382/**
380 * Ignore the next n calls to the log function. 383 * Ignore the next n calls to the log function.
381 * 384 *
382 * @param n number of log calls to ignore 385 * @param n number of log calls to ignore (could be negative)
383 * @param check_reset GNUNET_YES to assert that the log skip counter is currently zero 386 * @param check_reset GNUNET_YES to assert that the log skip counter is currently zero
384 */ 387 */
385void 388void
386GNUNET_log_skip (unsigned int n, int check_reset); 389GNUNET_log_skip (int n, int check_reset);
387 390
388 391
389/** 392/**
diff --git a/src/stream/test_stream_api.c b/src/stream/test_stream_api.c
index 20581f9b6..e78973dcf 100644
--- a/src/stream/test_stream_api.c
+++ b/src/stream/test_stream_api.c
@@ -78,6 +78,7 @@ static GNUNET_SCHEDULER_TaskIdentifier read_task;
78static char *data = "ABCD"; 78static char *data = "ABCD";
79static int result; 79static int result;
80 80
81
81/** 82/**
82 * Shutdown nicely 83 * Shutdown nicely
83 */ 84 */
diff --git a/src/util/common_logging.c b/src/util/common_logging.c
index ff11c7777..20f852c35 100644
--- a/src/util/common_logging.c
+++ b/src/util/common_logging.c
@@ -152,7 +152,7 @@ static struct CustomLogger *loggers;
152/** 152/**
153 * Number of log calls to ignore. 153 * Number of log calls to ignore.
154 */ 154 */
155unsigned int skip_log; 155int skip_log = 0;
156 156
157/** 157/**
158 * File descriptor to use for "stderr", or NULL for none. 158 * File descriptor to use for "stderr", or NULL for none.
@@ -810,11 +810,11 @@ flush_bulk (const char *datestr)
810/** 810/**
811 * Ignore the next n calls to the log function. 811 * Ignore the next n calls to the log function.
812 * 812 *
813 * @param n number of log calls to ignore 813 * @param n number of log calls to ignore (could be negative)
814 * @param check_reset GNUNET_YES to assert that the log skip counter is currently zero 814 * @param check_reset GNUNET_YES to assert that the log skip counter is currently zero
815 */ 815 */
816void 816void
817GNUNET_log_skip (unsigned int n, int check_reset) 817GNUNET_log_skip (int n, int check_reset)
818{ 818{
819 int ok; 819 int ok;
820 820
@@ -831,6 +831,16 @@ GNUNET_log_skip (unsigned int n, int check_reset)
831 } 831 }
832} 832}
833 833
834/**
835 * Get the number of log calls that are going to be skipped
836 *
837 * @return number of log calls to be ignored
838 */
839int
840GNUNET_get_log_skip ()
841{
842 return skip_log;
843}
834 844
835/** 845/**
836 * Output a log message using the default mechanism. 846 * Output a log message using the default mechanism.