mirror of
https://github.com/pocoproject/poco.git
synced 2025-01-18 00:15:27 +01:00
trunk/branch integration: fix
This commit is contained in:
parent
6f9ab52b38
commit
60bbdd7a6e
@ -64,13 +64,17 @@ SharedLibraryImpl::~SharedLibraryImpl()
|
||||
|
||||
void SharedLibraryImpl::loadImpl(const std::string& path)
|
||||
{
|
||||
FastMutex::ScopedLock lock(_mutex);
|
||||
FastMutex::ScopedLock lock(_mutex);
|
||||
|
||||
if (_handle) throw LibraryAlreadyLoadedException(path);
|
||||
_handle = dlopen(path.c_str(), RTLD_LAZY | RTLD_GLOBAL);
|
||||
if (!_handle)
|
||||
{
|
||||
const char* err = dlerror();
|
||||
if (_handle) throw LibraryAlreadyLoadedException(path);
|
||||
int flags = RTLD_LAZY | RTLD_GLOBAL;
|
||||
#if defined(RTLD_DEEPBIND)
|
||||
flags |= RTLD_DEEPBIND;
|
||||
#endif
|
||||
_handle = dlopen(path.c_str(), flags);
|
||||
if (!_handle)
|
||||
{
|
||||
const char* err = dlerror();
|
||||
throw LibraryLoadException(err ? std::string(err) : path);
|
||||
}
|
||||
_path = path;
|
||||
|
@ -35,6 +35,7 @@
|
||||
|
||||
|
||||
#include "Poco/SharedLibrary_WIN32.h"
|
||||
#include "Poco/Path.h"
|
||||
#include "Poco/UnWindows.h"
|
||||
|
||||
|
||||
@ -57,12 +58,12 @@ SharedLibraryImpl::~SharedLibraryImpl()
|
||||
|
||||
void SharedLibraryImpl::loadImpl(const std::string& path)
|
||||
{
|
||||
FastMutex::ScopedLock lock(_mutex);
|
||||
FastMutex::ScopedLock lock(_mutex);
|
||||
|
||||
if (_handle) throw LibraryAlreadyLoadedException(_path);
|
||||
_handle = LoadLibraryA(path.c_str());
|
||||
if (!_handle) throw LibraryLoadException(path);
|
||||
_path = path;
|
||||
if (_handle) throw LibraryAlreadyLoadedException(_path);
|
||||
_handle = LoadLibraryA(path.c_str());
|
||||
if (!_handle) throw LibraryLoadException(path);
|
||||
_path = path;
|
||||
}
|
||||
|
||||
|
||||
|
@ -36,6 +36,7 @@
|
||||
|
||||
#include "Poco/SharedLibrary_WIN32U.h"
|
||||
#include "Poco/UnicodeConverter.h"
|
||||
#include "Poco/Path.h"
|
||||
#include "Poco/UnWindows.h"
|
||||
|
||||
|
||||
@ -58,14 +59,19 @@ SharedLibraryImpl::~SharedLibraryImpl()
|
||||
|
||||
void SharedLibraryImpl::loadImpl(const std::string& path)
|
||||
{
|
||||
FastMutex::ScopedLock lock(_mutex);
|
||||
FastMutex::ScopedLock lock(_mutex);
|
||||
|
||||
if (_handle) throw LibraryAlreadyLoadedException(_path);
|
||||
std::wstring upath;
|
||||
UnicodeConverter::toUTF16(path, upath);
|
||||
_handle = LoadLibraryW(upath.c_str());
|
||||
if (!_handle) throw LibraryLoadException(path);
|
||||
_path = path;
|
||||
if (_handle) throw LibraryAlreadyLoadedException(_path);
|
||||
DWORD flags(0);
|
||||
#if !defined(_WIN32_WCE)
|
||||
Path p(path);
|
||||
if (p.isAbsolute()) flags |= LOAD_WITH_ALTERED_SEARCH_PATH;
|
||||
#endif
|
||||
std::wstring upath;
|
||||
UnicodeConverter::toUTF16(path, upath);
|
||||
_handle = LoadLibraryExW(upath.c_str(), 0, flags);
|
||||
if (!_handle) throw LibraryLoadException(path);
|
||||
_path = path;
|
||||
}
|
||||
|
||||
|
||||
@ -92,11 +98,17 @@ void* SharedLibraryImpl::findSymbolImpl(const std::string& name)
|
||||
{
|
||||
FastMutex::ScopedLock lock(_mutex);
|
||||
|
||||
if (_handle)
|
||||
{
|
||||
return (void*) GetProcAddress((HMODULE) _handle, name.c_str());
|
||||
}
|
||||
else return 0;
|
||||
if (_handle)
|
||||
{
|
||||
#if defined(_WIN32_WCE)
|
||||
std::wstring uname;
|
||||
UnicodeConverter::toUTF16(name, uname);
|
||||
return (void*) GetProcAddressW((HMODULE) _handle, uname.c_str());
|
||||
#else
|
||||
return (void*) GetProcAddress((HMODULE) _handle, name.c_str());
|
||||
#endif
|
||||
}
|
||||
else return 0;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user