diff options
author | Jan Safranek <jsafrane@redhat.com> | 2013-11-01 12:32:29 +0100 |
---|---|---|
committer | Jan Safranek <jsafrane@redhat.com> | 2013-11-01 12:32:29 +0100 |
commit | dd73461cec68d4ee72d54067c560451db70ddce8 (patch) | |
tree | 87ae9e5622f9829d346e84d0ec7d9875786d6c07 /src/openlmi.c | |
parent | 8e4f595d6b1861732d39564e9e1b8305d7987beb (diff) | |
download | openlmi-providers-dd73461cec68d4ee72d54067c560451db70ddce8.tar.gz openlmi-providers-dd73461cec68d4ee72d54067c560451db70ddce8.tar.xz openlmi-providers-dd73461cec68d4ee72d54067c560451db70ddce8.zip |
Work around Pegasus destroying threads _after_ unloading provider dynamic library.
Diffstat (limited to 'src/openlmi.c')
-rw-r--r-- | src/openlmi.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/openlmi.c b/src/openlmi.c index 1dc1b62..a13fc50 100644 --- a/src/openlmi.c +++ b/src/openlmi.c @@ -29,6 +29,7 @@ #include <stdio.h> #include <cmpimacs.h> #include <glib.h> +#include <dlfcn.h> static char *_system_name = NULL; static CMPIObjectPath *_computer_system = NULL; @@ -261,6 +262,8 @@ void lmi_init(const char *provider, const CMPIBroker *cb, const CMPIContext *ctx, const ConfigEntry *provider_config_defaults) { + static void *glib_loaded = 0; + pthread_mutex_lock(&_init_mutex); // Broker can change between threads _cb = cb; @@ -290,6 +293,18 @@ void lmi_init(const char *provider, const CMPIBroker *cb, get_computer_system(cb, ctx); } + /* + * Ugly hack to prevent Pegasus from crashing on cleanup. + * Glib2 adds some thread shutdown callback (see man pthread_key_create), + * but when cimprovagt destroys threads, this provider is already dlclosed(). + * So keep the libglib in memory so the callback does not crash. + * https://bugzilla.redhat.com/show_bug.cgi?id=1010238 + */ + if (!glib_loaded) { + glib_loaded = dlopen("libglib-2.0.so.0", RTLD_LAZY); + lmi_info("Loaded glib: %p\n", glib_loaded); + } + pthread_mutex_unlock(&_init_mutex); } |