]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/threadengines/threadengine_win32.cpp
Fix crash
[user/henk/code/inspircd.git] / src / threadengines / threadengine_win32.cpp
index 07d1b23733e21e8d00e07fd65aa0f0201c5a9a0f..180ded0ea16f049ce7a42b42b8648b26e8dc7051 100644 (file)
@@ -27,11 +27,11 @@ void Win32ThreadEngine::Create(Thread* thread_to_init)
        HANDLE* MyThread = new HANDLE;
        DWORD ThreadId = 0;
 
-       if (!(*MyThread = CreateThread(NULL,0,Win32ThreadEngine::Entry,this,0,&ThreadId)))
+       if (NULL == (*MyThread = CreateThread(NULL,0,Win32ThreadEngine::Entry,this,0,&ThreadId)))
        {
                delete MyThread;
                Mutex(false);
-               throw CoreException(std::string("Unable to reate new Win32ThreadEngine: ") + dlerror());
+               throw CoreException(std::string("Unable to create new Win32ThreadEngine: ") + dlerror());
        }
 
        NewThread = thread_to_init;
@@ -85,3 +85,30 @@ void Win32ThreadEngine::FreeThread(Thread* thread)
        }
 }
 
+
+MutexFactory::MutexFactory(InspIRCd* Instance) : ServerInstance(Instance)
+{
+}
+
+Mutex* MutexFactory::CreateMutex()
+{
+       return new Win32Mutex(this->ServerInstance);
+}
+
+Win32Mutex::Win32Mutex(InspIRCd* Instance) : Mutex(Instance)
+{
+       InitializeCriticalSection(&wutex);
+}
+
+Win32Mutex::~Win32Mutex()
+{
+       DeleteCriticalSection(&wutex);
+}
+
+void Win32Mutex::Enable(bool enable)
+{
+       if (enable)
+               EnterCriticalSection(&wutex);
+       else
+               LeaveCriticalSection(&wutex);
+}
\ No newline at end of file