diff options
| author | Jonathan "Geenz" Goodman <geenz@geenzo.com> | 2026-08-11 21:39:19 -0400 |
|---|---|---|
| committer | Jonathan "Geenz" Goodman <geenz@geenzo.com> | 2026-08-11 21:39:19 -0400 |
| commit | 8cabc33e960ca93fdc1a32c77cf611269d95d51b (patch) | |
| tree | 931fcecac10bf73214efa07cc3d704ba2bd01272 /indra/media_plugins/base/media_plugin_base.cpp | |
| parent | 9b7ab49575b54523128952af6686d17eb6696725 (diff) | |
| parent | d045f9aa32789a35628aced166145c182751acbf (diff) | |
Merge remote-tracking branch 'origin/develop-linux' into geenz/linux-to-develop
Diffstat (limited to 'indra/media_plugins/base/media_plugin_base.cpp')
| -rw-r--r-- | indra/media_plugins/base/media_plugin_base.cpp | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/indra/media_plugins/base/media_plugin_base.cpp b/indra/media_plugins/base/media_plugin_base.cpp index ccaa43cfb5..2e1e43d9e8 100644 --- a/indra/media_plugins/base/media_plugin_base.cpp +++ b/indra/media_plugins/base/media_plugin_base.cpp @@ -167,6 +167,55 @@ void MediaPluginBase::sendStatus() sendMessage(message); } +#if LL_LINUX + +#include <dlfcn.h> + +size_t SymbolGrabber::registerSymbol( SymbolToGrab aSymbol ) +{ + gSymbolsToGrab.emplace_back(aSymbol); + return gSymbolsToGrab.size(); +} + +bool SymbolGrabber::grabSymbols(std::vector< std::string > const &aDSONames) +{ + if (sSymsGrabbed) + return true; + + for( std::vector< std::string >::const_iterator itr = aDSONames.begin(); itr != aDSONames.end(); ++itr ) + { + auto pDSO = dlopen( itr->c_str(), RTLD_NOW ); + + if( pDSO ) + { + sLoadedLibraries.push_back(pDSO); + + for (auto i = 0; i < gSymbolsToGrab.size(); ++i) + { + if (!*gSymbolsToGrab[i].mPPFunc) + *gSymbolsToGrab[i].mPPFunc = dlsym(pDSO, gSymbolsToGrab[i].mName); + } + } + } + + bool sym_error = false; + + for( auto i = 0; i < gSymbolsToGrab.size(); ++i ) + { + if( gSymbolsToGrab[ i ].mRequired && ! *gSymbolsToGrab[ i ].mPPFunc ) + sym_error = true; + } + + sSymsGrabbed = !sym_error; + return sSymsGrabbed; +} + +void SymbolGrabber::ungrabSymbols() +{ + +} +#endif + #if LL_WINDOWS # define LLSYMEXPORT __declspec(dllexport) @@ -202,3 +251,50 @@ int WINAPI DllEntryPoint( HINSTANCE hInstance, unsigned long reason, void* param return 1; } #endif + +#if LL_LINUX +pid_t getParentPid( pid_t aPid ) +{ + std::stringstream strm; + strm << "/proc/" << aPid << "/status"; + std::ifstream in{ strm.str() }; + + if( !in.is_open() ) + return 0; + + pid_t res {0}; + while( !in.eof() && res == 0 ) + { + std::string line; + line.resize( 1024, 0 ); + in.getline( &line[0], line.length() ); + + auto i = line.find( "PPid:" ); + + if( i == std::string::npos ) + continue; + + char const *pIn = line.c_str() + 5; // Skip over pid; + while( *pIn != 0 && isspace( *pIn ) ) + ++pIn; + + if( *pIn ) + res = atoll( pIn ); + } + return res; +} + +bool isPluginPid( pid_t aPid ) +{ + auto myPid = getpid(); + + do + { + if( aPid == myPid ) + return true; + aPid = getParentPid( aPid ); + } while( aPid > 1 ); + + return false; +} +#endif |
