summaryrefslogtreecommitdiffstats
path: root/src/OSSupport
diff options
context:
space:
mode:
authorp-mcgowan <mickeymcgowan@shaw.ca>2014-12-05 20:24:09 +0100
committerp-mcgowan <mickeymcgowan@shaw.ca>2014-12-05 20:24:09 +0100
commita8bbd5efe422dd20a6bdcfc18cd0befbfeb93f9d (patch)
tree8c1fa6af38d8997f0cc935b62362245373b5db86 /src/OSSupport
parentreformat (diff)
parentCheckBasicStyle: Check missing braces for control statements. (diff)
downloadcuberite-a8bbd5efe422dd20a6bdcfc18cd0befbfeb93f9d.tar
cuberite-a8bbd5efe422dd20a6bdcfc18cd0befbfeb93f9d.tar.gz
cuberite-a8bbd5efe422dd20a6bdcfc18cd0befbfeb93f9d.tar.bz2
cuberite-a8bbd5efe422dd20a6bdcfc18cd0befbfeb93f9d.tar.lz
cuberite-a8bbd5efe422dd20a6bdcfc18cd0befbfeb93f9d.tar.xz
cuberite-a8bbd5efe422dd20a6bdcfc18cd0befbfeb93f9d.tar.zst
cuberite-a8bbd5efe422dd20a6bdcfc18cd0befbfeb93f9d.zip
Diffstat (limited to 'src/OSSupport')
-rw-r--r--src/OSSupport/Socket.h2
-rw-r--r--src/OSSupport/Thread.cpp11
2 files changed, 11 insertions, 2 deletions
diff --git a/src/OSSupport/Socket.h b/src/OSSupport/Socket.h
index e4ec895cb..9ec8c1111 100644
--- a/src/OSSupport/Socket.h
+++ b/src/OSSupport/Socket.h
@@ -74,7 +74,7 @@ public:
inline static bool IsSocketError(int a_ReturnedValue)
{
#ifdef _WIN32
- return (a_ReturnedValue == SOCKET_ERROR || a_ReturnedValue == 0);
+ return ((a_ReturnedValue == SOCKET_ERROR) || (a_ReturnedValue == 0));
#else
return (a_ReturnedValue <= 0);
#endif
diff --git a/src/OSSupport/Thread.cpp b/src/OSSupport/Thread.cpp
index faaccce96..6188d5088 100644
--- a/src/OSSupport/Thread.cpp
+++ b/src/OSSupport/Thread.cpp
@@ -83,12 +83,16 @@ cThread::~cThread()
void cThread::Start( bool a_bWaitOnDelete /* = true */)
{
if (a_bWaitOnDelete)
+ {
m_StopEvent = new cEvent();
+ }
#ifndef _WIN32
pthread_t SndThread;
if (pthread_create( &SndThread, NULL, MyThread, this))
+ {
LOGERROR("ERROR: Could not create thread!");
+ }
#else
DWORD ThreadID = 0;
HANDLE hThread = CreateThread(NULL // security
@@ -132,6 +136,11 @@ void *cThread::MyThread( void *a_Param)
ThreadFunction( ThreadParam);
- if (StopEvent) StopEvent->Set();
+ // If the thread was marked as wait-on-delete, signal the event being waited on:
+ if (StopEvent != nullptr)
+ {
+ StopEvent->Set();
+ }
+
return 0;
}