diff options
author | Matthew Newhook <matthew@zeroc.com> | 2008-06-05 16:06:18 +0800 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2008-06-06 15:28:20 +0200 |
commit | e60d0959e48e1b787bc52a4c998232f76c658278 (patch) | |
tree | 2c75c139c8a7eb5c455fb06f6cf1a26d04bd60a6 /cpp/src | |
parent | Fixed fix* scripts to not change file permissions (diff) | |
download | ice-e60d0959e48e1b787bc52a4c998232f76c658278.tar.bz2 ice-e60d0959e48e1b787bc52a4c998232f76c658278.tar.xz ice-e60d0959e48e1b787bc52a4c998232f76c658278.zip |
http://bugzilla.zeroc.com/bugzilla/show_bug.cgi?id=3239 - Under windows static mutexes can be destroyed too early
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/IceUtil/StaticMutex.cpp | 24 |
1 files changed, 5 insertions, 19 deletions
diff --git a/cpp/src/IceUtil/StaticMutex.cpp b/cpp/src/IceUtil/StaticMutex.cpp index 914398e8858..6206e245445 100644 --- a/cpp/src/IceUtil/StaticMutex.cpp +++ b/cpp/src/IceUtil/StaticMutex.cpp @@ -18,14 +18,14 @@ using namespace std; static CRITICAL_SECTION _criticalSection; -typedef list<CRITICAL_SECTION*> MutexList; - -static MutexList* _mutexList; - // // Although apparently not documented by Microsoft, static objects are // initialized before DllMain/DLL_PROCESS_ATTACH and finalized after -// DllMain/DLL_PROCESS_DETACH ... that's why we use a static object. +// DllMain/DLL_PROCESS_DETACH ... However, note that after the DLL is +// detached the allocated StaticMutexes may still be accessed. See +// http://blogs.msdn.com/larryosterman/archive/2004/06/10/152794.aspx +// for some details. This means that there is no convenient place to +// cleanup the globally allocated static mutexes. // namespace IceUtil @@ -36,7 +36,6 @@ class Init public: Init(); - ~Init(); }; static Init _init; @@ -44,20 +43,8 @@ static Init _init; Init::Init() { InitializeCriticalSection(&_criticalSection); - _mutexList = new MutexList; } -Init::~Init() -{ - for(MutexList::iterator p = _mutexList->begin(); - p != _mutexList->end(); ++p) - { - DeleteCriticalSection(*p); - delete *p; - } - delete _mutexList; - DeleteCriticalSection(&_criticalSection); -} } void IceUtil::StaticMutex::initialize() const @@ -81,7 +68,6 @@ void IceUtil::StaticMutex::initialize() const // void* oldVal = InterlockedCompareExchangePointer(reinterpret_cast<void**>(&_mutex), newMutex, 0); assert(oldVal == 0); - _mutexList->push_back(_mutex); } LeaveCriticalSection(&_criticalSection); |