summaryrefslogtreecommitdiff
path: root/src/threadengines
diff options
context:
space:
mode:
Diffstat (limited to 'src/threadengines')
-rw-r--r--src/threadengines/threadengine_pthread.cpp11
-rw-r--r--src/threadengines/threadengine_win32.cpp10
2 files changed, 13 insertions, 8 deletions
diff --git a/src/threadengines/threadengine_pthread.cpp b/src/threadengines/threadengine_pthread.cpp
index c1b964430..e16e401f3 100644
--- a/src/threadengines/threadengine_pthread.cpp
+++ b/src/threadengines/threadengine_pthread.cpp
@@ -80,6 +80,8 @@ class ThreadSignalSocket : public EventHandler
~ThreadSignalSocket()
{
+ ServerInstance->SE->DelFd(this);
+ ServerInstance->SE->Close(GetFd());
}
void Notify()
@@ -104,6 +106,7 @@ class ThreadSignalSocket : public EventHandler
SocketThread::SocketThread()
{
+ signal.sock = NULL;
int fd = eventfd(0, EFD_NONBLOCK);
if (fd < 0)
throw new CoreException("Could not create pipe " + std::string(strerror(errno)));
@@ -127,6 +130,8 @@ class ThreadSignalSocket : public EventHandler
~ThreadSignalSocket()
{
close(send_fd);
+ ServerInstance->SE->DelFd(this);
+ ServerInstance->SE->Close(GetFd());
}
void Notify()
@@ -152,6 +157,7 @@ class ThreadSignalSocket : public EventHandler
SocketThread::SocketThread()
{
+ signal.sock = NULL;
int fds[2];
if (pipe(fds))
throw new CoreException("Could not create pipe " + std::string(strerror(errno)));
@@ -166,4 +172,9 @@ void SocketThread::NotifyParent()
SocketThread::~SocketThread()
{
+ if (signal.sock)
+ {
+ signal.sock->cull();
+ delete signal.sock;
+ }
}
diff --git a/src/threadengines/threadengine_win32.cpp b/src/threadengines/threadengine_win32.cpp
index 529e24a29..ea37892f8 100644
--- a/src/threadengines/threadengine_win32.cpp
+++ b/src/threadengines/threadengine_win32.cpp
@@ -35,17 +35,11 @@ void ThreadEngine::Start(Thread* thread)
if (data->handle == NULL)
{
+ DWORD lasterr = GetLastError();
thread->state = NULL;
delete data;
- std::string err = "Unable to create new thread: ";
-#ifdef _WIN32
- CHAR errdetail[100];
- FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, 0, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), errdetail, 100, 0);
+ std::string err = "Unable to create new thread: " + ConvToStr(lasterr);
SetLastError(ERROR_SUCCESS);
- err += errdetail;
-#else
- err += dlerror();
-#endif
throw CoreException(err);
}
}