mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-28 09:31:03 +00:00
Make DynamicLibrary thread-safe w/r/t call to dlerror() after dlopen(). PR10718
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138260 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
11e03e7c2d
commit
eeb37f1a56
@ -72,6 +72,8 @@ static DenseSet<void *> *OpenedHandles = 0;
|
||||
|
||||
DynamicLibrary DynamicLibrary::getPermanentLibrary(const char *filename,
|
||||
std::string *errMsg) {
|
||||
SmartScopedLock<true> lock(getMutex());
|
||||
|
||||
void *handle = dlopen(filename, RTLD_LAZY|RTLD_GLOBAL);
|
||||
if (handle == 0) {
|
||||
if (errMsg) *errMsg = dlerror();
|
||||
@ -85,7 +87,6 @@ DynamicLibrary DynamicLibrary::getPermanentLibrary(const char *filename,
|
||||
handle = RTLD_DEFAULT;
|
||||
#endif
|
||||
|
||||
SmartScopedLock<true> lock(getMutex());
|
||||
if (OpenedHandles == 0)
|
||||
OpenedHandles = new DenseSet<void *>();
|
||||
|
||||
|
@ -71,9 +71,10 @@ extern "C" {
|
||||
|
||||
DynamicLibrary DynamicLibrary::getPermanentLibrary(const char *filename,
|
||||
std::string *errMsg) {
|
||||
SmartScopedLock<true> lock(getMutex());
|
||||
|
||||
if (!filename) {
|
||||
// When no file is specified, enumerate all DLLs and EXEs in the process.
|
||||
SmartScopedLock<true> lock(getMutex());
|
||||
if (OpenedHandles == 0)
|
||||
OpenedHandles = new DenseSet<HMODULE>();
|
||||
|
||||
@ -90,7 +91,6 @@ DynamicLibrary DynamicLibrary::getPermanentLibrary(const char *filename,
|
||||
return DynamicLibrary();
|
||||
}
|
||||
|
||||
SmartScopedLock<true> lock(getMutex());
|
||||
if (OpenedHandles == 0)
|
||||
OpenedHandles = new DenseSet<HMODULE>();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user