From 5ad96fb5a8c79fe50c21a726a7cbda4eaa3b96cc Mon Sep 17 00:00:00 2001 From: Venky Shankar Date: Mon, 27 Aug 2012 19:54:20 +0530 Subject: geo-rep / gsyncd: gsyncd binary wrapper context fixes Changes to __gf_calloc (commit ed4b76ba) triggers a recursive sequence of _gf_log() and __glusterfs_this_location() calls. This is due to __gf_calloc() trying to access THIS which is not valid in the context of geo replication binary wrapper. This patch fixes the problem by introducing the relevant context in the wrapper. Change-Id: I32b0b6927074692dbf66bad2f3e93434201aaa82 BUG: 846569 Signed-off-by: Venky Shankar Reviewed-on: http://review.gluster.org/3859 Reviewed-by: Csaba Henk Tested-by: Gluster Build System --- xlators/features/marker/utils/src/Makefile.am | 1 + xlators/features/marker/utils/src/gsyncd.c | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) (limited to 'xlators/features/marker') diff --git a/xlators/features/marker/utils/src/Makefile.am b/xlators/features/marker/utils/src/Makefile.am index 73c99cb76..de23fb556 100644 --- a/xlators/features/marker/utils/src/Makefile.am +++ b/xlators/features/marker/utils/src/Makefile.am @@ -13,6 +13,7 @@ noinst_HEADERS = procdiggy.h AM_CFLAGS = -fPIC -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -D$(GF_HOST_OS)\ -I$(top_srcdir)/libglusterfs/src\ -DGSYNCD_PREFIX=\"$(libexecdir)/glusterfs\"\ + -DUSE_LIBGLUSTERFS\ -DSBIN_DIR=\"$(sbindir)\" -DPYTHON=\"$(PYTHON)\" diff --git a/xlators/features/marker/utils/src/gsyncd.c b/xlators/features/marker/utils/src/gsyncd.c index cdf282673..a45873a71 100644 --- a/xlators/features/marker/utils/src/gsyncd.c +++ b/xlators/features/marker/utils/src/gsyncd.c @@ -19,6 +19,17 @@ #include #include /* for PATH_MAX */ +/* NOTE (USE_LIBGLUSTERFS): + * ------------------------ + * When USE_LIBGLUSTERFS debugging sumbol is passed; perform + * glusterfs translator like initialization so that glusterfs + * globals, contexts are valid when glustefs api's are invoked. + * We unconditionally pass then while building gsyncd binary. + */ +#ifdef USE_LIBGLUSTERFS +#include "glusterfs.h" +#include "globals.h" +#endif #include "common-utils.h" #include "run.h" @@ -290,6 +301,19 @@ main (int argc, char **argv) char *b = NULL; char *sargv = NULL; +#ifdef USE_LIBGLUSTERFS + glusterfs_ctx_t *ctx = NULL; + + ctx = glusterfs_ctx_new (); + if (!ctx) + return ENOMEM; + + if (glusterfs_globals_init (ctx)) + return 1; + + THIS->ctx = ctx; +#endif + evas = getenv (_GLUSTERD_CALLED_); if (evas && strcmp (evas, "1") == 0) /* OK, we know glusterd called us, no need to look for further config -- cgit