From: Christian P. <cp...@us...> - 2005-01-24 01:23:47
|
Update of /cvsroot/pclasses/pclasses2/src/System In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8954/src/System Modified Files: SharedLib.dl.cpp Log Message: Fixed unicode-string ctor. Index: SharedLib.dl.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/System/SharedLib.dl.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- SharedLib.dl.cpp 26 Dec 2004 14:38:05 -0000 1.9 +++ SharedLib.dl.cpp 24 Jan 2005 01:23:32 -0000 1.10 @@ -66,13 +66,24 @@ SharedLib::SharedLib(const Unicode::String& name, BindMode mode) throw(SystemError) { -// Please don't do this: -// Unicode::String realName = name; -// realName.append(".so"); + Cache& cache = shared_lib_cache<unsigned long, SharedLibCloser>(); + CriticalSection::ScopedLock lck(cache.mutex); - //@fixme _handle = (unsigned long)dlopen(realName.utf8(), BindMode2Flags(mode)); - if(!_handle) - throw SystemError(errno, dlerror(), P_SOURCEINFO); + // see if we can get it from the handle cache ... + Cache::iterator i = cache.lookup(name.utf8()); + if(i == cache.end()) + { + _handle = (unsigned long)dlopen(name.utf8().c_str(), BindMode2Flags(mode)); + if(!_handle) + throw SystemError(errno, dlerror(), P_SOURCEINFO); + + // add it to the handle cache + cache.add(name.utf8(), _handle); + } + else + { + _handle = i->second; + } } SharedLib::SharedLib(const std::string& name, BindMode mode) throw(SystemError) |