summaryrefslogtreecommitdiffstats
path: root/xlators/features
diff options
context:
space:
mode:
authorPrashanth Pai <ppai@redhat.com>2017-12-19 22:35:53 +0530
committerJeff Darcy <jeff@pl.atyp.us>2017-12-27 15:49:49 +0000
commitc6aad575171d4749d1ef2b5fc7c9fd7c32c1c59f (patch)
treea5752947f58fe52fea185117b710227211f23cb8 /xlators/features
parentee26765bdff77a4aa23efd0a8936d4306ec61c4b (diff)
Use RTLD_LOCAL for symbol resolution
RTLD_LOCAL is the default value for symbol visibility flag of dlopen() in Linux and NetBSD. Using it avoids conflicts during symbol resolution. This also allows us to detect xlators that have not been explicitly linked with libraries that they use. This used to go unnoticed when RTLD_GLOBAL was being used. BUG: 1193929 Change-Id: I50db6ea14ffdee96596060c4d6bf71cd3c432f7b Signed-off-by: Prashanth Pai <ppai@redhat.com>
Diffstat (limited to 'xlators/features')
-rw-r--r--xlators/features/glupy/src/glupy.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/xlators/features/glupy/src/glupy.c b/xlators/features/glupy/src/glupy.c
index bca476427c8..46d1af5533a 100644
--- a/xlators/features/glupy/src/glupy.c
+++ b/xlators/features/glupy/src/glupy.c
@@ -9,6 +9,7 @@
*/
#include <ctype.h>
+#include <dlfcn.h>
#include <sys/uio.h>
#include <Python.h>
@@ -2331,6 +2332,7 @@ init (xlator_t *this)
PyObject *error_bt = NULL;
static gf_boolean_t py_inited = _gf_false;
void * err_cleanup = &&err_return;
+ char libpython[16];
if (dict_get_str(this->options,"module-name",&module_name) != 0) {
gf_log (this->name, GF_LOG_ERROR, "missing module-name");
@@ -2345,6 +2347,23 @@ init (xlator_t *this)
err_cleanup = &&err_free_priv;
if (!py_inited) {
+ /* FIXME:
+ * This hack is necessary because glusterfs (rightly) loads
+ * glupy.so with RTLD_LOCAL but glupy needs libpython to be
+ * loaded with RTLD_GLOBAL even though glupy is correctly
+ * linked with libpython.
+ * This is needed because one of the internal modules of
+ * python 2.x (lib-dynload/_struct.so) does not explicitly
+ * link with libpython.
+ */
+ snprintf(libpython, sizeof(libpython), "libpython%d.%d.so",
+ PY_MAJOR_VERSION, PY_MINOR_VERSION);
+ if (!dlopen (libpython, RTLD_NOW|RTLD_GLOBAL)) {
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ LG_MSG_DLOPEN_FAILED, "dlopen(%s) failed: %s",
+ libpython, dlerror ());
+ }
+
/*
* This must be done before Py_Initialize(),
* because it will duplicate the environment,