]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/threadengines/threadengine_win32.cpp
Change allocation of InspIRCd::Users to be physically part of the object containing...
[user/henk/code/inspircd.git] / src / threadengines / threadengine_win32.cpp
index 637a3e01093877d75063c049aadd668afb4c34f5..c3a844a74957a3fc9b17b36ee9248d7abe750f0d 100644 (file)
@@ -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);
        }
 }
@@ -65,6 +59,7 @@ void ThreadData::FreeThread(Thread* thread)
 {
        thread->SetExitFlag();
        WaitForSingleObject(handle,INFINITE);
+       CloseHandle(handle);
 }
 
 class ThreadSignalSocket : public BufferedSocket
@@ -99,20 +94,20 @@ SocketThread::SocketThread()
 
        if (!ServerInstance->BindSocket(listenFD, 0, "127.0.0.1", true))
                throw CoreException("Could not create ITC pipe");
-       ServerInstance->SE->NonBlocking(connFD);
+       SocketEngine::NonBlocking(connFD);
 
        struct sockaddr_in addr;
        socklen_t sz = sizeof(addr);
        getsockname(listenFD, reinterpret_cast<struct sockaddr*>(&addr), &sz);
        connect(connFD, reinterpret_cast<struct sockaddr*>(&addr), sz);
-       ServerInstance->SE->Blocking(listenFD);
+       SocketEngine::Blocking(listenFD);
        int nfd = accept(listenFD, reinterpret_cast<struct sockaddr*>(&addr), &sz);
        if (nfd < 0)
                throw CoreException("Could not create ITC pipe");
        new ThreadSignalSocket(this, nfd);
        closesocket(listenFD);
 
-       ServerInstance->SE->Blocking(connFD);
+       SocketEngine::Blocking(connFD);
        this->signal.connFD = connFD;
 }