Fix a problem not letting plugins work when the client is built on RedHat and derived systems (Fedora is affected too). Completely avoid apr_dso_load() on Linux (they modified it to open libraries with RTLD_NOW | RTLD_GLOBAL | RTLD_DEEPBIND). Get a standard DSO handle with RTLD_NOW | RTLD_GLOBAL flags instead, and convert it to a valid APR one by using apr_os_handle_put().

This commit is contained in:
Player Dagostino
2011-08-02 20:15:58 +02:00
parent f3d6931fc3
commit a45de10024
5 changed files with 42 additions and 7 deletions

View File

@@ -28,6 +28,11 @@
* COMPLETENESS OR PERFORMANCE.
* $/LicenseInfo$
*/
#if LL_LINUX
#include <dlfcn.h>
#include <apr_portable.h>
#endif
#include "linden_common.h"
#include "apr_pools.h"
@@ -85,9 +90,15 @@ void LLImageJ2C::openDSO()
j2cimpl_dso_memory_pool.create();
//attempt to load the shared library
#if LL_LINUX
void *dso_handle = dlopen(dso_path.c_str(), RTLD_NOW | RTLD_GLOBAL);
rv = (!dso_handle)?APR_EDSOOPEN:apr_os_dso_handle_put(&j2cimpl_dso_handle,
dso_handle, j2cimpl_dso_memory_pool());
#else
rv = apr_dso_load(&j2cimpl_dso_handle,
dso_path.c_str(),
j2cimpl_dso_memory_pool());
#endif
//now, check for success
if ( rv == APR_SUCCESS )

View File

@@ -65,6 +65,9 @@ endif (NOT WORD_SIZE EQUAL 32)
list(APPEND llplugin_SOURCE_FILES ${llplugin_HEADER_FILES})
add_library (llplugin ${llplugin_SOURCE_FILES})
if(LINUX)
target_link_libraries (llplugin rt dl)
endif(LINUX)
add_dependencies(llplugin prepare)

View File

@@ -32,6 +32,10 @@
*
* @endcond
*/
#if LL_LINUX
#include <dlfcn.h>
#include <apr_portable.h>
#endif
#include "linden_common.h"
@@ -83,16 +87,25 @@ int LLPluginInstance::load(std::string &plugin_file)
{
pluginInitFunction init_function = NULL;
#if LL_LINUX
void *dso_handle = dlopen(plugin_file.c_str(), RTLD_NOW | RTLD_GLOBAL);
int result = (!dso_handle)?APR_EDSOOPEN:apr_os_dso_handle_put(&mDSOHandle,
dso_handle, AIAPRRootPool::get()());
#else
int result = apr_dso_load(&mDSOHandle,
plugin_file.c_str(),
AIAPRRootPool::get()());
#endif
if(result != APR_SUCCESS)
{
char buf[1024];
apr_dso_error(mDSOHandle, buf, sizeof(buf));
#if LL_LINUX
LL_WARNS("Plugin") << "plugin load " << plugin_file << " failed with error " << result << " , additional info string: " << buf << LL_ENDL;
#else
LL_WARNS("Plugin") << "apr_dso_load of " << plugin_file << " failed with error " << result << " , additional info string: " << buf << LL_ENDL;
#endif
}
if(result == APR_SUCCESS)

View File

@@ -32,6 +32,9 @@
#if LL_DBUS_ENABLED
#include <dlfcn.h>
#include <apr_portable.h>
#include "linden_common.h"
extern "C" {
@@ -71,9 +74,11 @@ bool grab_dbus_syms(std::string dbus_dso_name)
//attempt to load the shared library
apr_pool_create(&sSymDBUSDSOMemoryPool, NULL);
if ( APR_SUCCESS == (rv = apr_dso_load(&sSymDBUSDSOHandle,
dbus_dso_name.c_str(),
sSymDBUSDSOMemoryPool) ))
void *dso_handle = dlopen(dbus_dso_name.c_str(), RTLD_NOW | RTLD_GLOBAL);
rv = (!dso_handle)?APR_EDSOOPEN:apr_os_dso_handle_put(&sSymDBUSDSOHandle,
dso_handle, sSymDBUSDSOMemoryPool);
if ( APR_SUCCESS == rv )
{
INFOMSG("Found DSO: %s", dbus_dso_name.c_str());

View File

@@ -52,6 +52,8 @@ extern "C" {
#include "aiaprpool.h"
#include "apr_dso.h"
#include <dlfcn.h>
#include <apr_portable.h>
}
////////////////////////////////////////////////////
@@ -87,9 +89,10 @@ bool grab_pa_syms(std::string pulse_dso_name)
//attempt to load the shared library
sSymPADSOMemoryPool.create();
if ( APR_SUCCESS == (rv = apr_dso_load(&sSymPADSOHandle,
pulse_dso_name.c_str(),
sSymPADSOMemoryPool()) ))
void *dso_handle = dlopen(pulse_dso_name.c_str(), RTLD_NOW | RTLD_GLOBAL);
rv = (!dso_handle)?APR_EDSOOPEN:apr_os_dso_handle_put(&sSymPADSOHandle,
dso_handle, sSymPADSOMemoryPool());
if ( APR_SUCCESS == rv )
{
INFOMSG("Found DSO: %s", pulse_dso_name.c_str());