[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [gnunet] branch master updated: towards thread-safe logging
From: |
gnunet |
Subject: |
[GNUnet-SVN] [gnunet] branch master updated: towards thread-safe logging |
Date: |
Thu, 09 May 2019 14:54:26 +0200 |
This is an automated email from the git hooks/post-receive script.
dold pushed a commit to branch master
in repository gnunet.
The following commit(s) were added to refs/heads/master by this push:
new 67c331462 towards thread-safe logging
67c331462 is described below
commit 67c3314628930be7e6a9d224456c8dac0f4c8fd4
Author: Florian Dold <address@hidden>
AuthorDate: Thu May 9 14:51:50 2019 +0200
towards thread-safe logging
(Thread-safe logging isn't really relevant for GNUnet itself, but it is
necessary for the GNU Taler exchange)
---
configure.ac | 14 ++++++++++++++
src/include/platform.h | 6 +++++-
src/util/common_logging.c | 12 ++++++------
3 files changed, 25 insertions(+), 7 deletions(-)
diff --git a/configure.ac b/configure.ac
index e00b8ae1b..b1e1c1aca 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1795,6 +1795,20 @@ else
fi
AC_DEFINE_UNQUOTED([ENABLE_WINDOWS_WORKAROUNDS], $workarounds, [enable
workarounds used on Windows (only useful for test cases)])
+
+# Check if the __thread storage class for thread-local storage is available.
+AC_MSG_CHECKING(whether __thread is supported)
+AC_LINK_IFELSE(
+ [AC_LANG_PROGRAM([#include <stdlib.h>
+ #undef __thread
+ static __thread int a = 1;],
+ [exit(a-1);])],
+ [have_thread_local_gcc=1],[have_thread_local_gcc=0])
+AC_DEFINE_UNQUOTED([HAVE_THREAD_LOCAL_GCC],$have_thread_local_gcc,[Define this
if __thread is supported])
+AS_IF([test "x$have_thread_local_gcc" = "x1"],
+ [AC_MSG_RESULT(yes)],
+ [AC_MSG_RESULT(no)])
+
# gcov compilation
AC_MSG_CHECKING(whether to compile with support for code coverage analysis)
AC_ARG_ENABLE([coverage],
diff --git a/src/include/platform.h b/src/include/platform.h
index 01b0bcf9e..23e640ec1 100644
--- a/src/include/platform.h
+++ b/src/include/platform.h
@@ -289,6 +289,10 @@ atoll (const char *nptr);
#define PATH_MAX 4096
#endif
-
+#if HAVE_THREAD_LOCAL_GCC
+#define GNUNET_THREAD_LOCAL __thread
+#else
+#define GNUNET_THREAD_LOCAL
+#endif
#endif
diff --git a/src/util/common_logging.c b/src/util/common_logging.c
index de30cab3a..34002e0fc 100644
--- a/src/util/common_logging.c
+++ b/src/util/common_logging.c
@@ -100,27 +100,27 @@ struct CustomLogger
* Note that this message maybe truncated to the first BULK_TRACK_SIZE
* characters, in which case it is NOT 0-terminated!
*/
-static char last_bulk[BULK_TRACK_SIZE] __attribute__ ((nonstring));
+static GNUNET_THREAD_LOCAL char last_bulk[BULK_TRACK_SIZE] __attribute__
((nonstring));
/**
* Type of the last bulk message.
*/
-static enum GNUNET_ErrorType last_bulk_kind;
+static GNUNET_THREAD_LOCAL enum GNUNET_ErrorType last_bulk_kind;
/**
* Time of the last bulk error message (0 for none)
*/
-static struct GNUNET_TIME_Absolute last_bulk_time;
+static GNUNET_THREAD_LOCAL struct GNUNET_TIME_Absolute last_bulk_time;
/**
* Number of times that bulk message has been repeated since.
*/
-static unsigned int last_bulk_repeat;
+static GNUNET_THREAD_LOCAL unsigned int last_bulk_repeat;
/**
* Component when the last bulk was logged. Will be 0-terminated.
*/
-static char last_bulk_comp[COMP_TRACK_SIZE + 1];
+static GNUNET_THREAD_LOCAL char last_bulk_comp[COMP_TRACK_SIZE + 1];
/**
* Running component.
@@ -150,7 +150,7 @@ static struct CustomLogger *loggers;
/**
* Number of log calls to ignore.
*/
-static int skip_log = 0;
+static GNUNET_THREAD_LOCAL int skip_log = 0;
/**
* File descriptor to use for "stderr", or NULL for none.
--
To stop receiving notification emails like this one, please contact
address@hidden
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] [gnunet] branch master updated: towards thread-safe logging,
gnunet <=