From 7fb3abaeae763b99ef387804b46943051ac6cbbc Mon Sep 17 00:00:00 2001 From: Poornima G Date: Sat, 19 Mar 2016 04:38:47 -0400 Subject: gfapi: Fix the crashes caused by global_xlator and THIS Issue: http://thread.gmane.org/gmane.comp.file-systems.gluster.devel/10922 The right fix for this is elaborate and intrusive, until it is in place, this patch provides a temperory fix. This fix is necessary, as without this libgfapi applications like qemu, samba, NFS ganesha are prone to crashes. This patch will be reverted completely, once the actual fix gets accepted. Change-Id: Ic975ab0bb03ba415cdf9bddba1534ba4d2d2820c BUG: 1319374 Signed-off-by: Poornima G Reviewed-on: http://review.gluster.org/13784 Smoke: Gluster Build System Reviewed-by: Shyamsundar Ranganathan Reviewed-by: Jeff Darcy NetBSD-regression: NetBSD Build System CentOS-regression: Gluster Build System --- libglusterfs/src/globals.c | 7 ++++++- libglusterfs/src/logging.c | 4 ++-- libglusterfs/src/logging.h | 2 +- libglusterfs/src/unittest/log_mock.c | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) (limited to 'libglusterfs') diff --git a/libglusterfs/src/globals.c b/libglusterfs/src/globals.c index 3cc29c5491c..435921d64cc 100644 --- a/libglusterfs/src/globals.c +++ b/libglusterfs/src/globals.c @@ -72,6 +72,11 @@ const char *gf_fop_list[GF_FOP_MAXVALUE] = { }; /* THIS */ +/* This global ctx is a bad hack to prevent some of the libgfapi crashes. + * This should be removed once the patch on resource pool is accepted + */ +glusterfs_ctx_t *global_ctx = NULL; +pthread_mutex_t global_ctx_mutex = PTHREAD_MUTEX_INITIALIZER; xlator_t global_xlator; static pthread_key_t this_xlator_key; static pthread_key_t synctask_key; @@ -383,7 +388,7 @@ glusterfs_globals_init (glusterfs_ctx_t *ctx) { int ret = 0; - gf_log_globals_init (ctx); + gf_log_globals_init (ctx, GF_LOG_INFO); ret = pthread_once (&globals_inited, gf_globals_init_once); diff --git a/libglusterfs/src/logging.c b/libglusterfs/src/logging.c index 1d7ac4c785b..62f19b9d3e3 100644 --- a/libglusterfs/src/logging.c +++ b/libglusterfs/src/logging.c @@ -642,13 +642,13 @@ gf_syslog (int facility_priority, char *format, ...) } void -gf_log_globals_init (void *data) +gf_log_globals_init (void *data, gf_loglevel_t level) { glusterfs_ctx_t *ctx = data; pthread_mutex_init (&ctx->log.logfile_mutex, NULL); - ctx->log.loglevel = GF_LOG_INFO; + ctx->log.loglevel = level; ctx->log.gf_log_syslog = 1; ctx->log.sys_log_level = GF_LOG_CRITICAL; ctx->log.logger = gf_logger_glusterlog; diff --git a/libglusterfs/src/logging.h b/libglusterfs/src/logging.h index 25a9e42d71c..3c7346f8cc7 100644 --- a/libglusterfs/src/logging.h +++ b/libglusterfs/src/logging.h @@ -134,7 +134,7 @@ typedef struct log_buf_ { struct list_head msg_list; } log_buf_t; -void gf_log_globals_init (void *ctx); +void gf_log_globals_init (void *ctx, gf_loglevel_t level); int gf_log_init (void *data, const char *filename, const char *ident); void gf_log_logrotate (int signum); diff --git a/libglusterfs/src/unittest/log_mock.c b/libglusterfs/src/unittest/log_mock.c index b35e03b3618..c03ff524612 100644 --- a/libglusterfs/src/unittest/log_mock.c +++ b/libglusterfs/src/unittest/log_mock.c @@ -47,4 +47,4 @@ int _gf_msg_nomem (const char *domain, const char *file, } void -gf_log_globals_init (void *data) {} +gf_log_globals_init (void *data, gf_loglevel_t level) {} -- cgit