diff options
author | Nicky Dasmijn <nicky.dasmijn@posteo.nl> | 2024-10-01 00:11:04 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-01 01:11:04 +0300 |
commit | 5112aa396db2b3eac15970f65b9c5fb149fd8ce1 (patch) | |
tree | 70c4c196c79ad9ecc0ed35056868feba3d6968b7 | |
parent | 78e4c84ef65ba3e10e18de7a9bf5a5a77257b6ab (diff) |
Linux: Remove APR from Linux-Symbolgrabber (#2743)
dlopen and dlsym are well suited for and let us avoid the need to deal with the pecularities of APR.
-rw-r--r-- | indra/media_plugins/base/media_plugin_base.cpp | 23 | ||||
-rw-r--r-- | indra/media_plugins/base/media_plugin_base.h | 7 |
2 files changed, 14 insertions, 16 deletions
diff --git a/indra/media_plugins/base/media_plugin_base.cpp b/indra/media_plugins/base/media_plugin_base.cpp index 9bb3bad035..f31708c4d7 100644 --- a/indra/media_plugins/base/media_plugin_base.cpp +++ b/indra/media_plugins/base/media_plugin_base.cpp @@ -169,6 +169,8 @@ void MediaPluginBase::sendStatus() #if LL_LINUX +#include <dlfcn.h> + size_t SymbolGrabber::registerSymbol( SymbolToGrab aSymbol ) { gSymbolsToGrab.emplace_back(aSymbol); @@ -177,25 +179,22 @@ size_t SymbolGrabber::registerSymbol( SymbolToGrab aSymbol ) bool SymbolGrabber::grabSymbols(std::vector< std::string > const &aDSONames) { - std::cerr << "SYMBOLS: " << gSymbolsToGrab.size() << std::endl; - if (sSymsGrabbed) return true; - //attempt to load the shared libraries - apr_pool_create(&sSymDSOMemoryPool, nullptr); - for( std::vector< std::string >::const_iterator itr = aDSONames.begin(); itr != aDSONames.end(); ++itr ) { - apr_dso_handle_t *pDSO(NULL); - std::string strDSO{ *itr }; - if( APR_SUCCESS == apr_dso_load( &pDSO, strDSO.c_str(), sSymDSOMemoryPool )) - sLoadedLibraries.push_back( pDSO ); + auto pDSO = dlopen( itr->c_str(), RTLD_NOW ); - for( auto i = 0; i < gSymbolsToGrab.size(); ++i ) + if( pDSO ) { - if( !*gSymbolsToGrab[i].mPPFunc ) - apr_dso_sym( gSymbolsToGrab[i].mPPFunc, pDSO, gSymbolsToGrab[i].mName ); + sLoadedLibraries.push_back(pDSO); + + for (auto i = 0; i < gSymbolsToGrab.size(); ++i) + { + if (!*gSymbolsToGrab[i].mPPFunc) + *gSymbolsToGrab[i].mPPFunc = dlsym(pDSO, gSymbolsToGrab[i].mName); + } } } diff --git a/indra/media_plugins/base/media_plugin_base.h b/indra/media_plugins/base/media_plugin_base.h index a084fc9834..98e9ce0316 100644 --- a/indra/media_plugins/base/media_plugin_base.h +++ b/indra/media_plugins/base/media_plugin_base.h @@ -38,7 +38,7 @@ struct SymbolToGrab { bool mRequired; char const *mName; - apr_dso_handle_sym_t *mPPFunc; + void **mPPFunc; }; class SymbolGrabber @@ -52,8 +52,7 @@ private: std::vector< SymbolToGrab > gSymbolsToGrab; bool sSymsGrabbed = false; - apr_pool_t *sSymDSOMemoryPool = nullptr; - std::vector<apr_dso_handle_t *> sLoadedLibraries; + std::vector<void *> sLoadedLibraries; }; extern SymbolGrabber gSymbolGrabber; @@ -63,7 +62,7 @@ extern SymbolGrabber gSymbolGrabber; #define LL_GRAB_SYM(SYMBOL_GRABBER, REQUIRED, SYMBOL_NAME, RETURN, ...) \ RETURN (*ll##SYMBOL_NAME)(__VA_ARGS__) = nullptr; \ size_t gRegistered##SYMBOL_NAME = SYMBOL_GRABBER.registerSymbol( \ - { REQUIRED, #SYMBOL_NAME , (apr_dso_handle_sym_t*)&ll##SYMBOL_NAME} \ + { REQUIRED, #SYMBOL_NAME , (void**)&ll##SYMBOL_NAME} \ ); #endif |