mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-03-01 01:30:36 +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,
|
DynamicLibrary DynamicLibrary::getPermanentLibrary(const char *filename,
|
||||||
std::string *errMsg) {
|
std::string *errMsg) {
|
||||||
|
SmartScopedLock<true> lock(getMutex());
|
||||||
|
|
||||||
void *handle = dlopen(filename, RTLD_LAZY|RTLD_GLOBAL);
|
void *handle = dlopen(filename, RTLD_LAZY|RTLD_GLOBAL);
|
||||||
if (handle == 0) {
|
if (handle == 0) {
|
||||||
if (errMsg) *errMsg = dlerror();
|
if (errMsg) *errMsg = dlerror();
|
||||||
@ -85,7 +87,6 @@ DynamicLibrary DynamicLibrary::getPermanentLibrary(const char *filename,
|
|||||||
handle = RTLD_DEFAULT;
|
handle = RTLD_DEFAULT;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SmartScopedLock<true> lock(getMutex());
|
|
||||||
if (OpenedHandles == 0)
|
if (OpenedHandles == 0)
|
||||||
OpenedHandles = new DenseSet<void *>();
|
OpenedHandles = new DenseSet<void *>();
|
||||||
|
|
||||||
|
@ -71,9 +71,10 @@ extern "C" {
|
|||||||
|
|
||||||
DynamicLibrary DynamicLibrary::getPermanentLibrary(const char *filename,
|
DynamicLibrary DynamicLibrary::getPermanentLibrary(const char *filename,
|
||||||
std::string *errMsg) {
|
std::string *errMsg) {
|
||||||
|
SmartScopedLock<true> lock(getMutex());
|
||||||
|
|
||||||
if (!filename) {
|
if (!filename) {
|
||||||
// When no file is specified, enumerate all DLLs and EXEs in the process.
|
// When no file is specified, enumerate all DLLs and EXEs in the process.
|
||||||
SmartScopedLock<true> lock(getMutex());
|
|
||||||
if (OpenedHandles == 0)
|
if (OpenedHandles == 0)
|
||||||
OpenedHandles = new DenseSet<HMODULE>();
|
OpenedHandles = new DenseSet<HMODULE>();
|
||||||
|
|
||||||
@ -90,7 +91,6 @@ DynamicLibrary DynamicLibrary::getPermanentLibrary(const char *filename,
|
|||||||
return DynamicLibrary();
|
return DynamicLibrary();
|
||||||
}
|
}
|
||||||
|
|
||||||
SmartScopedLock<true> lock(getMutex());
|
|
||||||
if (OpenedHandles == 0)
|
if (OpenedHandles == 0)
|
||||||
OpenedHandles = new DenseSet<HMODULE>();
|
OpenedHandles = new DenseSet<HMODULE>();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user