diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-06-23 22:25:58 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-06-23 22:25:58 +0000 |
commit | 4beaf8200aa658c15d2b138d1754983a7eb253e3 (patch) | |
tree | e8e5e437af639442354355a2ab95a328b2a1a1fa /src | |
parent | d30c25b427875a16cc46cfd091f595f119e570bc (diff) | |
download | gnunet-4beaf8200aa658c15d2b138d1754983a7eb253e3.tar.gz gnunet-4beaf8200aa658c15d2b138d1754983a7eb253e3.zip |
-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.
Diffstat (limited to 'src')
-rw-r--r-- | src/util/common_logging.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/util/common_logging.c b/src/util/common_logging.c index 20f852c35..6c3dda9bc 100644 --- a/src/util/common_logging.c +++ b/src/util/common_logging.c | |||
@@ -737,6 +737,10 @@ GNUNET_logger_remove (GNUNET_Logger logger, void *logger_cls) | |||
737 | GNUNET_free (pos); | 737 | GNUNET_free (pos); |
738 | } | 738 | } |
739 | 739 | ||
740 | #if WINDOWS | ||
741 | CRITICAL_SECTION output_message_cs; | ||
742 | #endif | ||
743 | |||
740 | 744 | ||
741 | /** | 745 | /** |
742 | * Actually output the log message. | 746 | * Actually output the log message. |
@@ -751,7 +755,9 @@ output_message (enum GNUNET_ErrorType kind, const char *comp, | |||
751 | const char *datestr, const char *msg) | 755 | const char *datestr, const char *msg) |
752 | { | 756 | { |
753 | struct CustomLogger *pos; | 757 | struct CustomLogger *pos; |
754 | 758 | #if WINDOWS | |
759 | EnterCriticalSection (&output_message_cs); | ||
760 | #endif | ||
755 | if (NULL != GNUNET_stderr) | 761 | if (NULL != GNUNET_stderr) |
756 | { | 762 | { |
757 | FPRINTF (GNUNET_stderr, "%s %s %s %s", datestr, comp, | 763 | FPRINTF (GNUNET_stderr, "%s %s %s %s", datestr, comp, |
@@ -764,6 +770,9 @@ output_message (enum GNUNET_ErrorType kind, const char *comp, | |||
764 | pos->logger (pos->logger_cls, kind, comp, datestr, msg); | 770 | pos->logger (pos->logger_cls, kind, comp, datestr, msg); |
765 | pos = pos->next; | 771 | pos = pos->next; |
766 | } | 772 | } |
773 | #if WINDOWS | ||
774 | LeaveCriticalSection (&output_message_cs); | ||
775 | #endif | ||
767 | } | 776 | } |
768 | 777 | ||
769 | 778 | ||
@@ -1141,6 +1150,10 @@ void __attribute__ ((constructor)) GNUNET_util_cl_init () | |||
1141 | #ifdef MINGW | 1150 | #ifdef MINGW |
1142 | GNInitWinEnv (NULL); | 1151 | GNInitWinEnv (NULL); |
1143 | #endif | 1152 | #endif |
1153 | #if WINDOWS | ||
1154 | if (!InitializeCriticalSectionAndSpinCount (&output_message_cs, 0x00000400)) | ||
1155 | GNUNET_abort (); | ||
1156 | #endif | ||
1144 | } | 1157 | } |
1145 | 1158 | ||
1146 | 1159 | ||
@@ -1149,6 +1162,9 @@ void __attribute__ ((constructor)) GNUNET_util_cl_init () | |||
1149 | */ | 1162 | */ |
1150 | void __attribute__ ((destructor)) GNUNET_util_cl_fini () | 1163 | void __attribute__ ((destructor)) GNUNET_util_cl_fini () |
1151 | { | 1164 | { |
1165 | #if WINDOWS | ||
1166 | DeleteCriticalSection (&output_message_cs); | ||
1167 | #endif | ||
1152 | #ifdef MINGW | 1168 | #ifdef MINGW |
1153 | GNShutdownWinEnv (); | 1169 | GNShutdownWinEnv (); |
1154 | #endif | 1170 | #endif |