summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src/logging.c
diff options
context:
space:
mode:
Diffstat (limited to 'libglusterfs/src/logging.c')
-rw-r--r--libglusterfs/src/logging.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/libglusterfs/src/logging.c b/libglusterfs/src/logging.c
index 147ee383751..70149a2fd3c 100644
--- a/libglusterfs/src/logging.c
+++ b/libglusterfs/src/logging.c
@@ -292,6 +292,18 @@ log_buf_init (log_buf_t *buf, const char *domain, const char *file,
int errnum, uint64_t msgid, char **appmsgstr, int graph_id)
{
int ret = -1;
+ xlator_t *old_THIS;
+ extern xlator_t global_xlator;
+
+ /*
+ * The current translator will be put in the block header for any
+ * memory block we allocate here. Unfortunately, these objects might
+ * outlive the current translator, and if we then try to dereference
+ * that pointer we go BOOM. Since this is really a global structure,
+ * use the global translator.
+ */
+ old_THIS = THIS;
+ THIS = &global_xlator;
if (!buf || !domain || !file || !function || !appmsgstr || !*appmsgstr)
goto out;
@@ -322,6 +334,7 @@ log_buf_init (log_buf_t *buf, const char *domain, const char *file,
ret = 0;
out:
+ THIS = old_THIS;
return ret;
}