trunk/branch integration: fix

This commit is contained in:
Marian Krivos
2011-08-23 07:03:10 +00:00
parent 6f9ab52b38
commit 60bbdd7a6e
3 changed files with 40 additions and 23 deletions

View File

@@ -64,13 +64,17 @@ SharedLibraryImpl::~SharedLibraryImpl()
void SharedLibraryImpl::loadImpl(const std::string& path) void SharedLibraryImpl::loadImpl(const std::string& path)
{ {
FastMutex::ScopedLock lock(_mutex); FastMutex::ScopedLock lock(_mutex);
if (_handle) throw LibraryAlreadyLoadedException(path); if (_handle) throw LibraryAlreadyLoadedException(path);
_handle = dlopen(path.c_str(), RTLD_LAZY | RTLD_GLOBAL); int flags = RTLD_LAZY | RTLD_GLOBAL;
if (!_handle) #if defined(RTLD_DEEPBIND)
{ flags |= RTLD_DEEPBIND;
const char* err = dlerror(); #endif
_handle = dlopen(path.c_str(), flags);
if (!_handle)
{
const char* err = dlerror();
throw LibraryLoadException(err ? std::string(err) : path); throw LibraryLoadException(err ? std::string(err) : path);
} }
_path = path; _path = path;

View File

@@ -35,6 +35,7 @@
#include "Poco/SharedLibrary_WIN32.h" #include "Poco/SharedLibrary_WIN32.h"
#include "Poco/Path.h"
#include "Poco/UnWindows.h" #include "Poco/UnWindows.h"
@@ -57,12 +58,12 @@ SharedLibraryImpl::~SharedLibraryImpl()
void SharedLibraryImpl::loadImpl(const std::string& path) void SharedLibraryImpl::loadImpl(const std::string& path)
{ {
FastMutex::ScopedLock lock(_mutex); FastMutex::ScopedLock lock(_mutex);
if (_handle) throw LibraryAlreadyLoadedException(_path); if (_handle) throw LibraryAlreadyLoadedException(_path);
_handle = LoadLibraryA(path.c_str()); _handle = LoadLibraryA(path.c_str());
if (!_handle) throw LibraryLoadException(path); if (!_handle) throw LibraryLoadException(path);
_path = path; _path = path;
} }

View File

@@ -36,6 +36,7 @@
#include "Poco/SharedLibrary_WIN32U.h" #include "Poco/SharedLibrary_WIN32U.h"
#include "Poco/UnicodeConverter.h" #include "Poco/UnicodeConverter.h"
#include "Poco/Path.h"
#include "Poco/UnWindows.h" #include "Poco/UnWindows.h"
@@ -58,14 +59,19 @@ SharedLibraryImpl::~SharedLibraryImpl()
void SharedLibraryImpl::loadImpl(const std::string& path) void SharedLibraryImpl::loadImpl(const std::string& path)
{ {
FastMutex::ScopedLock lock(_mutex); FastMutex::ScopedLock lock(_mutex);
if (_handle) throw LibraryAlreadyLoadedException(_path); if (_handle) throw LibraryAlreadyLoadedException(_path);
std::wstring upath; DWORD flags(0);
UnicodeConverter::toUTF16(path, upath); #if !defined(_WIN32_WCE)
_handle = LoadLibraryW(upath.c_str()); Path p(path);
if (!_handle) throw LibraryLoadException(path); if (p.isAbsolute()) flags |= LOAD_WITH_ALTERED_SEARCH_PATH;
_path = 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); FastMutex::ScopedLock lock(_mutex);
if (_handle) if (_handle)
{ {
return (void*) GetProcAddress((HMODULE) _handle, name.c_str()); #if defined(_WIN32_WCE)
} std::wstring uname;
else return 0; 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;
} }