Skip to content

Commit

Permalink
put shared variables into thread-local storage
Browse files Browse the repository at this point in the history
This doesn't solve the general design problem of the log.c (eg; some log lines
got lost or scattered into multiple files) but at least prevent multithreaded
code from crashing.

Before this change something like following;

sudo src/tests/lxc-test-concurrent -i 10 -j 20

was crashing nearly all the time due to 3afbcc4 as we started to
set lxc.loglevel and lxc.logfile with that commit.

Signed-off-by: S.Çağlar Onur <caglar@10ur.org>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
  • Loading branch information
caglar10ur authored and hallyn committed Mar 7, 2014
1 parent e5ab821 commit dc5406b
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/lxc/log.c
Expand Up @@ -41,13 +41,23 @@
#define LXC_LOG_BUFFER_SIZE 512

int lxc_log_fd = -1;
#ifdef HAVE_TLS
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
* values from the configuration file or defaults
*/
static __thread int lxc_logfile_specified = 0;
static __thread int lxc_loglevel_specified = 0;
#else
static char log_prefix[LXC_LOG_PREFIX_SIZE] = "lxc";
static char *log_fname = NULL;
/* command line values for logfile or logpriority should always override
* values from the configuration file or defaults
*/
static int lxc_logfile_specified = 0;
static int lxc_loglevel_specified = 0;
#endif

lxc_log_define(lxc_log, lxc);

Expand Down

0 comments on commit dc5406b

Please sign in to comment.