gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r22239 - gnunet/src/util


From: gnunet
Subject: [GNUnet-SVN] r22239 - gnunet/src/util
Date: Sun, 24 Jun 2012 00:25:58 +0200

Author: grothoff
Date: 2012-06-24 00:25:58 +0200 (Sun, 24 Jun 2012)
New Revision: 22239

Modified:
   gnunet/src/util/common_logging.c
Log:
-LRN: Lock the output on W32:
  Purely W32 patch. It was needed for some threading-related debugging
i did for select() wrapper. Shouldn't harm to have it, in case i do
logging from multiple threads again.




Modified: gnunet/src/util/common_logging.c
===================================================================
--- gnunet/src/util/common_logging.c    2012-06-23 22:24:50 UTC (rev 22238)
+++ gnunet/src/util/common_logging.c    2012-06-23 22:25:58 UTC (rev 22239)
@@ -737,7 +737,11 @@
   GNUNET_free (pos);
 }
 
+#if WINDOWS
+CRITICAL_SECTION output_message_cs;
+#endif
 
+
 /**
  * Actually output the log message.
  *
@@ -751,7 +755,9 @@
                 const char *datestr, const char *msg)
 {
   struct CustomLogger *pos;
-
+#if WINDOWS
+  EnterCriticalSection (&output_message_cs);
+#endif
   if (NULL != GNUNET_stderr)
   {
     FPRINTF (GNUNET_stderr, "%s %s %s %s", datestr, comp,
@@ -764,6 +770,9 @@
     pos->logger (pos->logger_cls, kind, comp, datestr, msg);
     pos = pos->next;
   }
+#if WINDOWS
+  LeaveCriticalSection (&output_message_cs);
+#endif
 }
 
 
@@ -1141,6 +1150,10 @@
 #ifdef MINGW
   GNInitWinEnv (NULL);
 #endif
+#if WINDOWS
+  if (!InitializeCriticalSectionAndSpinCount (&output_message_cs, 0x00000400))
+    GNUNET_abort ();
+#endif
 }
 
 
@@ -1149,6 +1162,9 @@
  */
 void __attribute__ ((destructor)) GNUNET_util_cl_fini ()
 {
+#if WINDOWS
+  DeleteCriticalSection (&output_message_cs);
+#endif
 #ifdef MINGW
   GNShutdownWinEnv ();
 #endif




reply via email to

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