From 40df30d258ebfd24a447fababc649867c24513d8 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Tue, 10 Sep 2024 16:55:32 +0200 Subject: Split SystemException to handle Windows Windows has (at least) two error namespaces, both errno and GetLastResult(). These overlap, so it is important we keep track of which one we are dealing with. To make things extra problematic, the BSD socket API normally uses errno, but on Windows it has been mapped in to the GetLastResult() namespace. Try to keep better control of this by using separate classes for the namespaces. --- common/os/Thread.cxx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'common/os/Thread.cxx') diff --git a/common/os/Thread.cxx b/common/os/Thread.cxx index 91f7fd07..e99be63e 100644 --- a/common/os/Thread.cxx +++ b/common/os/Thread.cxx @@ -66,7 +66,7 @@ void Thread::start() #ifdef WIN32 *(HANDLE*)threadId = CreateThread(nullptr, 0, startRoutine, this, 0, nullptr); if (*(HANDLE*)threadId == nullptr) - throw rdr::SystemException("Failed to create thread", GetLastError()); + throw rdr::Win32Exception("Failed to create thread", GetLastError()); #else int ret; sigset_t all, old; @@ -76,14 +76,14 @@ void Thread::start() sigfillset(&all); ret = pthread_sigmask(SIG_SETMASK, &all, &old); if (ret != 0) - throw rdr::SystemException("Failed to mask signals", ret); + throw rdr::PosixException("Failed to mask signals", ret); ret = pthread_create((pthread_t*)threadId, nullptr, startRoutine, this); pthread_sigmask(SIG_SETMASK, &old, nullptr); if (ret != 0) - throw rdr::SystemException("Failed to create thread", ret); + throw rdr::PosixException("Failed to create thread", ret); #endif running = true; @@ -99,13 +99,13 @@ void Thread::wait() ret = WaitForSingleObject(*(HANDLE*)threadId, INFINITE); if (ret != WAIT_OBJECT_0) - throw rdr::SystemException("Failed to join thread", GetLastError()); + throw rdr::Win32Exception("Failed to join thread", GetLastError()); #else int ret; ret = pthread_join(*(pthread_t*)threadId, nullptr); if (ret != 0) - throw rdr::SystemException("Failed to join thread", ret); + throw rdr::PosixException("Failed to join thread", ret); #endif } -- cgit v1.2.3