1
0
Fork 0

CriticalSectionLocker unlock bug

This commit is contained in:
Nukem 2014-12-20 23:13:53 -05:00
parent f35bc34506
commit 6f781e0d0d
2 changed files with 7 additions and 1 deletions

View File

@ -53,20 +53,25 @@ CriticalSectionLocker::CriticalSectionLocker(CriticalSectionLock lock)
{
CriticalSectionInitializeLocks(); //initialize critical sections
gLock = lock;
EnterCriticalSection(&locks[gLock]);
Locked = true;
}
CriticalSectionLocker::~CriticalSectionLocker()
{
LeaveCriticalSection(&locks[gLock]);
if(Locked)
LeaveCriticalSection(&locks[gLock]);
}
void CriticalSectionLocker::unlock()
{
Locked = false;
LeaveCriticalSection(&locks[gLock]);
}
void CriticalSectionLocker::relock()
{
EnterCriticalSection(&locks[gLock]);
Locked = true;
}

View File

@ -46,6 +46,7 @@ public:
private:
CriticalSectionLock gLock;
bool Locked;
};
#endif // _THREADING_H