]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/threadengines/threadengine_pthread.cpp
Numerous fixes for m_dccallow - only the first banfile tag mattered, improper behavio...
[user/henk/code/inspircd.git] / src / threadengines / threadengine_pthread.cpp
index 626cd4d55528b6670e8f0d136e96300723205f55..69b900c5b15f6032d951f6c8c5fe6c880f5a7187 100644 (file)
@@ -14,6 +14,7 @@
 #include "inspircd.h"
 #include "threadengines/threadengine_pthread.h"
 #include <pthread.h>
+#include <signal.h>
 
 pthread_mutex_t MyMutex = PTHREAD_MUTEX_INITIALIZER;
 
@@ -87,6 +88,13 @@ bool PThreadEngine::Mutex(bool enable)
 
 void* PThreadEngine::Entry(void* parameter)
 {
+       /* Recommended by nenolod, signal safety on a per-thread basis */
+       sigset_t set;
+       sigemptyset(&set);
+       sigaddset(&set, SIGPIPE);
+       if(pthread_sigmask(SIG_BLOCK, &set, NULL))
+               signal(SIGPIPE, SIG_IGN);
+
        ThreadEngine * pt = (ThreadEngine*)parameter;
        pt->Run();
        return NULL;
@@ -105,23 +113,23 @@ void PThreadEngine::FreeThread(Thread* thread)
        }
 }
 
-MutexEngine::MutexEngine(InspIRCd* Instance) : ServerInstance(Instance)
+MutexFactory::MutexFactory(InspIRCd* Instance) : ServerInstance(Instance)
 {
 }
 
-Mutex* MutexEngine::CreateMutex()
+Mutex* MutexFactory::CreateMutex()
 {
        return new PosixMutex(this->ServerInstance);
 }
 
 PosixMutex::PosixMutex(InspIRCd* Instance) : Mutex(Instance)
 {
-       InitializeCriticalSection(&putex);
+       pthread_mutex_init(&putex, NULL);
 }
 
 PosixMutex::~PosixMutex()
 {
-       DeleteCriticalSection(&putex);
+       pthread_mutex_destroy(&putex);
 }
 
 void PosixMutex::Enable(bool enable)