Switched cEvent to use strerror_r for error messages
This commit is contained in:
parent
435eae3858
commit
7419579140
@ -7,7 +7,9 @@
|
|||||||
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
|
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
|
||||||
|
|
||||||
#include "Event.h"
|
#include "Event.h"
|
||||||
|
#if not defined(_WIN32)
|
||||||
|
#include <string.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -35,14 +37,18 @@ cEvent::cEvent(void)
|
|||||||
m_Event = sem_open(EventName.c_str(), O_CREAT, 777, 0 );
|
m_Event = sem_open(EventName.c_str(), O_CREAT, 777, 0 );
|
||||||
if (m_Event == SEM_FAILED)
|
if (m_Event == SEM_FAILED)
|
||||||
{
|
{
|
||||||
LOGERROR("cEvent: Cannot create event, errno = %i. Aborting server.", errno);
|
char buffer[1024];
|
||||||
|
strerror_r(errno,buffer,1024);
|
||||||
|
LOGERROR("cEvent: Cannot create event, err = %s. Aborting server.", buffer);
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
// Unlink the semaphore immediately - it will continue to function but will not pollute the namespace
|
// 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
|
// We don't store the name, so can't call this in the destructor
|
||||||
if (sem_unlink(EventName.c_str()) != 0)
|
if (sem_unlink(EventName.c_str()) != 0)
|
||||||
{
|
{
|
||||||
LOGWARN("ERROR: Could not unlink cEvent. (%i)", errno);
|
char buffer[1024];
|
||||||
|
strerror_r(errno,buffer,1024);
|
||||||
|
LOGWARN("ERROR: Could not unlink cEvent. (%s)", buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // *nix
|
#endif // *nix
|
||||||
@ -61,7 +67,9 @@ cEvent::~cEvent()
|
|||||||
{
|
{
|
||||||
if (sem_close(m_Event) != 0)
|
if (sem_close(m_Event) != 0)
|
||||||
{
|
{
|
||||||
LOGERROR("ERROR: Could not close cEvent. (%i)", errno);
|
char buffer[1024];
|
||||||
|
strerror_r(errno,buffer,1024);
|
||||||
|
LOGERROR("ERROR: Could not close cEvent. (%s)", buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -88,7 +96,9 @@ void cEvent::Wait(void)
|
|||||||
int res = sem_wait(m_Event);
|
int res = sem_wait(m_Event);
|
||||||
if (res != 0 )
|
if (res != 0 )
|
||||||
{
|
{
|
||||||
LOGWARN("cEvent: waiting for the event failed: %i, errno = %i. Continuing, but server may be unstable.", res, errno);
|
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);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -108,7 +118,9 @@ void cEvent::Set(void)
|
|||||||
int res = sem_post(m_Event);
|
int res = sem_post(m_Event);
|
||||||
if (res != 0)
|
if (res != 0)
|
||||||
{
|
{
|
||||||
LOGWARN("cEvent: Could not set cEvent: %i, errno = %d", res, errno);
|
char buffer[1024];
|
||||||
|
strerror_r(errno,buffer,1024);
|
||||||
|
LOGWARN("cEvent: Could not set cEvent: %i, err = %s", res, buffer);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user