[lxc-devel] [PATCH] add shared lxc_log_fd into TLS

S.Çağlar Onur caglar at 10ur.org
Fri Mar 7 05:05:23 UTC 2014


Signed-off-by: S.Çağlar Onur <caglar at 10ur.org>
---
 src/lxc/log.c | 3 ++-
 src/lxc/log.h | 6 ++++++
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/lxc/log.c b/src/lxc/log.c
index 1dd1aa8..a9f98a4 100644
--- a/src/lxc/log.c
+++ b/src/lxc/log.c
@@ -40,8 +40,8 @@
 #define LXC_LOG_PREFIX_SIZE	32
 #define LXC_LOG_BUFFER_SIZE	512
 
-int lxc_log_fd = -1;
 #ifdef HAVE_TLS
+__thread int lxc_log_fd = -1;
 static __thread char log_prefix[LXC_LOG_PREFIX_SIZE] = "lxc";
 static __thread char *log_fname = NULL;
 /* command line values for logfile or logpriority should always override
@@ -50,6 +50,7 @@ static __thread char *log_fname = NULL;
 static __thread int lxc_logfile_specified = 0;
 static __thread int lxc_loglevel_specified = 0;
 #else
+int lxc_log_fd = -1;
 static char log_prefix[LXC_LOG_PREFIX_SIZE] = "lxc";
 static char *log_fname = NULL;
 /* command line values for logfile or logpriority should always override
diff --git a/src/lxc/log.h b/src/lxc/log.h
index ff8e47d..5252869 100644
--- a/src/lxc/log.h
+++ b/src/lxc/log.h
@@ -24,6 +24,8 @@
 #ifndef _log_h
 #define _log_h
 
+#include "config.h"
+
 #include <stdarg.h>
 #include <stdio.h>
 #include <sys/time.h>
@@ -285,7 +287,11 @@ static inline void LXC_##PRIORITY(struct lxc_log_locinfo* locinfo,	\
 	ERROR("%s - " format, strerror(errno), ##__VA_ARGS__);		\
 } while (0)
 
+#ifdef HAVE_TLS
+extern __thread int lxc_log_fd;
+#else
 extern int lxc_log_fd;
+#endif
 
 extern int lxc_log_init(const char *name, const char *file,
 			const char *priority, const char *prefix, int quiet,
-- 
1.8.3.2



More information about the lxc-devel mailing list