gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r22238 - in gnunet/src: hostlist include stream util


From: gnunet
Subject: [GNUnet-SVN] r22238 - in gnunet/src: hostlist include stream util
Date: Sun, 24 Jun 2012 00:24:50 +0200

Author: grothoff
Date: 2012-06-24 00:24:50 +0200 (Sun, 24 Jun 2012)
New Revision: 22238

Modified:
   gnunet/src/hostlist/test_gnunet_daemon_hostlist.c
   gnunet/src/hostlist/test_gnunet_daemon_hostlist_learning.c
   gnunet/src/include/gnunet_common.h
   gnunet/src/stream/test_stream_api.c
   gnunet/src/util/common_logging.c
Log:
-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.



Modified: gnunet/src/hostlist/test_gnunet_daemon_hostlist.c
===================================================================
--- gnunet/src/hostlist/test_gnunet_daemon_hostlist.c   2012-06-23 22:07:20 UTC 
(rev 22237)
+++ gnunet/src/hostlist/test_gnunet_daemon_hostlist.c   2012-06-23 22:24:50 UTC 
(rev 22238)
@@ -27,11 +27,7 @@
 #include "gnunet_arm_service.h"
 #include "gnunet_transport_service.h"
 
-#define VERBOSE GNUNET_NO
 
-#define START_ARM GNUNET_YES
-
-
 /**
  * How long until we give up on transmitting the message?
  */
@@ -47,9 +43,7 @@
   struct GNUNET_TRANSPORT_Handle *th;
   struct GNUNET_MessageHeader *hello;
   struct GNUNET_TRANSPORT_GetHelloHandle *ghh;
-#if START_ARM
   struct GNUNET_OS_Process *arm_proc;
-#endif
 };
 
 static struct PeerContext p1;
@@ -138,12 +132,10 @@
 setup_peer (struct PeerContext *p, const char *cfgname)
 {
   p->cfg = GNUNET_CONFIGURATION_create ();
-#if START_ARM
   p->arm_proc =
       GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
                                "gnunet-service-arm",
                                "-c", cfgname, NULL);
-#endif
   GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
   p->th =
       GNUNET_TRANSPORT_connect (p->cfg, NULL, p, NULL, &notify_connect, NULL);
@@ -157,7 +149,6 @@
 {
   struct PeerContext *p = cls;
 
-#if START_ARM
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Killing ARM process.\n");
   if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM))
     GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
@@ -167,7 +158,6 @@
               GNUNET_OS_process_get_pid (p->arm_proc));
   GNUNET_OS_process_destroy (p->arm_proc);
   p->arm_proc = NULL;
-#endif
   GNUNET_CONFIGURATION_destroy (p->cfg);
 }
 

Modified: gnunet/src/hostlist/test_gnunet_daemon_hostlist_learning.c
===================================================================
--- gnunet/src/hostlist/test_gnunet_daemon_hostlist_learning.c  2012-06-23 
22:07:20 UTC (rev 22237)
+++ gnunet/src/hostlist/test_gnunet_daemon_hostlist_learning.c  2012-06-23 
22:24:50 UTC (rev 22238)
@@ -30,8 +30,6 @@
 #include "gnunet_resolver_service.h"
 #include "gnunet_statistics_service.h"
 
-#define START_ARM GNUNET_YES
-
 #define MAX_URL_LEN 1000
 
 /**
@@ -49,9 +47,7 @@
   struct GNUNET_MessageHeader *hello;
   struct GNUNET_CORE_Handle *core;
   struct GNUNET_STATISTICS_Handle *stats;
-#if START_ARM
   struct GNUNET_OS_Process *arm_proc;
-#endif
 };
 
 static int timeout;
@@ -147,7 +143,6 @@
     GNUNET_CORE_disconnect (learn_peer.core);
     learn_peer.core = NULL;
   }
-#if START_ARM
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Killing hostlist server ARM process.\n");
   if (0 != GNUNET_OS_process_kill (adv_peer.arm_proc, SIGTERM))
@@ -164,7 +159,6 @@
     GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
   GNUNET_OS_process_destroy (learn_peer.arm_proc);
   learn_peer.arm_proc = NULL;
-#endif
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutdown complete....\n");
 }
 
@@ -390,12 +384,10 @@
   unsigned int result;
 
   p->cfg = GNUNET_CONFIGURATION_create ();
-#if START_ARM
   p->arm_proc =
     GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
                                "gnunet-service-arm",
                                "-c", cfgname, NULL);
-#endif
   GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
   if (GNUNET_OK ==
       GNUNET_CONFIGURATION_get_value_string (p->cfg, "HOSTLIST", 
"HOSTLISTFILE",
@@ -423,12 +415,10 @@
 setup_adv_peer (struct PeerContext *p, const char *cfgname)
 {
   p->cfg = GNUNET_CONFIGURATION_create ();
-#if START_ARM
   p->arm_proc =
     GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
                                "gnunet-service-arm",
                                "-c", cfgname, NULL);
-#endif
   GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
   p->stats = GNUNET_STATISTICS_create ("hostlist", p->cfg);
   GNUNET_assert (NULL != p->stats);

Modified: gnunet/src/include/gnunet_common.h
===================================================================
--- gnunet/src/include/gnunet_common.h  2012-06-23 22:07:20 UTC (rev 22237)
+++ gnunet/src/include/gnunet_common.h  2012-06-23 22:24:50 UTC (rev 22238)
@@ -284,9 +284,12 @@
 
 
 /**
- * Number of log calls to ignore.
+ * Get the number of log calls that are going to be skipped
+ *
+ * @return number of log calls to be ignored
  */
-extern unsigned int skip_log;
+int
+GNUNET_get_log_skip ();
 
 #if !defined(GNUNET_CULL_LOGGING)
 int
@@ -344,7 +347,7 @@
   if ((GNUNET_EXTRA_LOGGING > 0) || ((GNUNET_ERROR_TYPE_DEBUG & (kind)) == 0)) 
{ \
     if (GN_UNLIKELY(log_call_enabled == -1))\
       log_call_enabled = GNUNET_get_log_call_status ((kind) & 
(~GNUNET_ERROR_TYPE_BULK), (comp), __FILE__, __FUNCTION__, log_line); \
-    if (GN_UNLIKELY(skip_log > 0)) {skip_log--;}\
+    if (GN_UNLIKELY(GNUNET_get_log_skip () > 0)) { GNUNET_log_skip (-1, 
GNUNET_NO); }\
     else {\
       if (GN_UNLIKELY(log_call_enabled))\
         GNUNET_log_from_nocheck ((kind), comp, __VA_ARGS__);   \
@@ -357,7 +360,7 @@
   if ((GNUNET_EXTRA_LOGGING > 0) || ((GNUNET_ERROR_TYPE_DEBUG & (kind)) == 0)) 
{ \
     if (GN_UNLIKELY(log_call_enabled == -1))\
       log_call_enabled = GNUNET_get_log_call_status ((kind) & 
(~GNUNET_ERROR_TYPE_BULK), NULL, __FILE__, __FUNCTION__, log_line);\
-    if (GN_UNLIKELY(skip_log > 0)) {skip_log--;}\
+    if (GN_UNLIKELY(GNUNET_get_log_skip () > 0)) { GNUNET_log_skip (-1, 
GNUNET_NO); }\
     else {\
       if (GN_UNLIKELY(log_call_enabled))\
         GNUNET_log_nocheck ((kind), __VA_ARGS__);      \
@@ -379,11 +382,11 @@
 /**
  * Ignore the next n calls to the log function.
  *
- * @param n number of log calls to ignore
+ * @param n number of log calls to ignore (could be negative)
  * @param check_reset GNUNET_YES to assert that the log skip counter is 
currently zero
  */
 void
-GNUNET_log_skip (unsigned int n, int check_reset);
+GNUNET_log_skip (int n, int check_reset);
 
 
 /**

Modified: gnunet/src/stream/test_stream_api.c
===================================================================
--- gnunet/src/stream/test_stream_api.c 2012-06-23 22:07:20 UTC (rev 22237)
+++ gnunet/src/stream/test_stream_api.c 2012-06-23 22:24:50 UTC (rev 22238)
@@ -78,6 +78,7 @@
 static char *data = "ABCD";
 static int result;
 
+
 /**
  * Shutdown nicely
  */

Modified: gnunet/src/util/common_logging.c
===================================================================
--- gnunet/src/util/common_logging.c    2012-06-23 22:07:20 UTC (rev 22237)
+++ gnunet/src/util/common_logging.c    2012-06-23 22:24:50 UTC (rev 22238)
@@ -152,7 +152,7 @@
 /**
  * Number of log calls to ignore.
  */
-unsigned int skip_log;
+int skip_log = 0;
 
 /**
  * File descriptor to use for "stderr", or NULL for none.
@@ -810,11 +810,11 @@
 /**
  * Ignore the next n calls to the log function.
  *
- * @param n number of log calls to ignore
+ * @param n number of log calls to ignore (could be negative)
  * @param check_reset GNUNET_YES to assert that the log skip counter is 
currently zero
  */
 void
-GNUNET_log_skip (unsigned int n, int check_reset)
+GNUNET_log_skip (int n, int check_reset)
 {
   int ok;
 
@@ -831,6 +831,16 @@
   }
 }
 
+/**
+ * Get the number of log calls that are going to be skipped
+ *
+ * @return number of log calls to be ignored
+ */
+int
+GNUNET_get_log_skip ()
+{
+  return skip_log;
+}
 
 /**
  * Output a log message using the default mechanism.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]