From dd78e555f8b86754197823e267fe80712b59c30d Mon Sep 17 00:00:00 2001 From: Akash Mozumdar Date: Wed, 8 Aug 2018 23:56:36 -0400 Subject: [PATCH] bugfix concurrency --- host/host.cc | 2 +- host/textthread.cc | 2 +- host/winmutex.h | 16 ++++++++-------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/host/host.cc b/host/host.cc index d52b33d..ba38953 100644 --- a/host/host.cc +++ b/host/host.cc @@ -24,7 +24,7 @@ ProcessEventCallback onAttach, onDetach; WORD nextThreadNumber; HWND dummyWindow; -#define HOST_LOCK CriticalSectionLocker hostLocker(hostCs) // Synchronized scope for accessing private data +#define HOST_LOCK CriticalSectionLocker hostLocker(&hostCs) // Synchronized scope for accessing private data void GetDebugPrivileges() // Artikash 5/19/2018: Is it just me or is this function 100% superfluous? { diff --git a/host/textthread.cc b/host/textthread.cc index e98a3de..37d824d 100644 --- a/host/textthread.cc +++ b/host/textthread.cc @@ -11,7 +11,7 @@ extern HWND dummyWindow; -#define TT_LOCK CriticalSectionLocker ttLocker(ttCs) // Synchronized scope for accessing private data +#define TT_LOCK CriticalSectionLocker ttLocker(&ttCs) // Synchronized scope for accessing private data TextThread::TextThread(ThreadParameter tp, unsigned int threadNumber, DWORD status) : storage(), diff --git a/host/winmutex.h b/host/winmutex.h index a3b79b9..d94890d 100644 --- a/host/winmutex.h +++ b/host/winmutex.h @@ -12,24 +12,24 @@ class MutexLocker { - HANDLE m; + HANDLE mutex; public: - explicit MutexLocker(HANDLE mutex) : m(mutex) + explicit MutexLocker(HANDLE mutex) : mutex(mutex) { - WaitForSingleObject(m, 0); + WaitForSingleObject(mutex, 0); } - ~MutexLocker() { if (m != INVALID_HANDLE_VALUE && m != nullptr) ReleaseMutex(m); } + ~MutexLocker() { if (mutex != INVALID_HANDLE_VALUE && mutex != nullptr) ReleaseMutex(mutex); } }; class CriticalSectionLocker { - CRITICAL_SECTION cs; + CRITICAL_SECTION* cs; public: - explicit CriticalSectionLocker(CRITICAL_SECTION cs) : cs(cs) + explicit CriticalSectionLocker(CRITICAL_SECTION* cs) : cs(cs) { - EnterCriticalSection(&cs); + EnterCriticalSection(cs); } - ~CriticalSectionLocker() { LeaveCriticalSection(&cs); } + ~CriticalSectionLocker() { LeaveCriticalSection(cs); } }; // EOF