summaryrefslogtreecommitdiffstats
path: root/src/OSSupport/Event.cpp
diff options
context:
space:
mode:
authorTycho <work.tycho+git@gmail.com>2014-01-25 15:02:20 +0100
committerTycho <work.tycho+git@gmail.com>2014-01-25 15:02:20 +0100
commit977e277094750a22284b4a738269db295af3cad3 (patch)
treeaa9eae879e5a124fe888a445b55516b414dd2a2d /src/OSSupport/Event.cpp
parentExtracted cSocket::GetErrorString into GetOSErrorString (diff)
downloadcuberite-977e277094750a22284b4a738269db295af3cad3.tar
cuberite-977e277094750a22284b4a738269db295af3cad3.tar.gz
cuberite-977e277094750a22284b4a738269db295af3cad3.tar.bz2
cuberite-977e277094750a22284b4a738269db295af3cad3.tar.lz
cuberite-977e277094750a22284b4a738269db295af3cad3.tar.xz
cuberite-977e277094750a22284b4a738269db295af3cad3.tar.zst
cuberite-977e277094750a22284b4a738269db295af3cad3.zip
Diffstat (limited to '')
-rw-r--r--src/OSSupport/Event.cpp29
1 files changed, 11 insertions, 18 deletions
diff --git a/src/OSSupport/Event.cpp b/src/OSSupport/Event.cpp
index fe1128dc9..649a0a3cf 100644
--- a/src/OSSupport/Event.cpp
+++ b/src/OSSupport/Event.cpp
@@ -7,9 +7,7 @@
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
#include "Event.h"
-#if not defined(_WIN32)
-#include <string.h>
-#endif
+#include "Errors.h"
@@ -37,18 +35,16 @@ cEvent::cEvent(void)
m_Event = sem_open(EventName.c_str(), O_CREAT, 777, 0 );
if (m_Event == SEM_FAILED)
{
- char buffer[1024];
- strerror_r(errno,buffer,1024);
- LOGERROR("cEvent: Cannot create event, err = %s. Aborting server.", buffer);
+ AString error = GetOSErrorString(errno);
+ LOGERROR("cEvent: Cannot create event, err = %s. Aborting server.", error.c_str());
abort();
}
// Unlink the semaphore immediately - it will continue to function but will not pollute the namespace
// We don't store the name, so can't call this in the destructor
if (sem_unlink(EventName.c_str()) != 0)
{
- char buffer[1024];
- strerror_r(errno,buffer,1024);
- LOGWARN("ERROR: Could not unlink cEvent. (%s)", buffer);
+ AString error = GetOSErrorString(errno);
+ LOGWARN("ERROR: Could not unlink cEvent. (%s)", error.c_str());
}
}
#endif // *nix
@@ -67,9 +63,8 @@ cEvent::~cEvent()
{
if (sem_close(m_Event) != 0)
{
- char buffer[1024];
- strerror_r(errno,buffer,1024);
- LOGERROR("ERROR: Could not close cEvent. (%s)", buffer);
+ AString error = GetOSErrorString(errno);
+ LOGERROR("ERROR: Could not close cEvent. (%s)", error.c_str());
}
}
else
@@ -96,9 +91,8 @@ void cEvent::Wait(void)
int res = sem_wait(m_Event);
if (res != 0 )
{
- char buffer[1024];
- strerror_r(errno,buffer,1024);
- LOGWARN("cEvent: waiting for the event failed: %i, err = %s. Continuing, but server may be unstable.", res, buffer);
+ AString error = GetOSErrorString(errno);
+ LOGWARN("cEvent: waiting for the event failed: %i, err = %s. Continuing, but server may be unstable.", res, error.c_str());
}
#endif
}
@@ -118,9 +112,8 @@ void cEvent::Set(void)
int res = sem_post(m_Event);
if (res != 0)
{
- char buffer[1024];
- strerror_r(errno,buffer,1024);
- LOGWARN("cEvent: Could not set cEvent: %i, err = %s", res, buffer);
+ AString error = GetOSErrorString(errno);
+ LOGWARN("cEvent: Could not set cEvent: %i, err = %s", res, error.c_str());
}
#endif
}