chore(JSON): add stringify unicode tests #4707 (#4720)

* chore(JSON): add stringify unicode tests #4707

* enh(Mutex): Error code for pthread_mutex_lock failure #4712
This commit is contained in:
Aleksandar Fabijanic
2024-10-14 06:48:45 -05:00
committed by GitHub
parent 8e958f685f
commit 71a085c1dc
8 changed files with 88 additions and 47 deletions

View File

@@ -43,6 +43,9 @@ public:
static std::string getMessage(int errorCode);
/// Utility function translating numeric error code to string.
#endif
static std::string getLastMessage();
/// Utility function returning the last error message.
};

View File

@@ -20,8 +20,8 @@
#include "Poco/Foundation.h"
#include "Poco/Exception.h"
#include "Poco/Error.h"
#include <pthread.h>
#include <errno.h>
namespace Poco {
@@ -56,8 +56,9 @@ protected:
//
inline void MutexImpl::lockImpl()
{
if (pthread_mutex_lock(&_mutex))
throw SystemException("cannot lock mutex");
int rc;
if ((rc = pthread_mutex_lock(&_mutex)))
throw SystemException("cannot lock mutex", Error::getMessage(rc));
}
@@ -69,14 +70,15 @@ inline bool MutexImpl::tryLockImpl()
else if (rc == EBUSY)
return false;
else
throw SystemException("cannot lock mutex");
throw SystemException("cannot lock mutex", Error::getMessage(rc));
}
inline void MutexImpl::unlockImpl()
{
if (pthread_mutex_unlock(&_mutex))
throw SystemException("cannot unlock mutex");
int rc;
if ((rc = pthread_mutex_unlock(&_mutex)))
throw SystemException("cannot unlock mutex", Error::getMessage(rc));
}

View File

@@ -20,6 +20,7 @@
#include "Poco/Foundation.h"
#include "Poco/Exception.h"
#include "Poco/Error.h"
#include "Poco/UnWindows.h"
@@ -55,7 +56,7 @@ inline void MutexImpl::lockImpl()
}
catch (...)
{
throw SystemException("cannot lock mutex");
throw SystemException("cannot lock mutex", Error::getLastMessage());
}
}
@@ -69,7 +70,7 @@ inline bool MutexImpl::tryLockImpl()
catch (...)
{
}
throw SystemException("cannot lock mutex");
throw SystemException("cannot lock mutex", Error::getLastMessage());
}

View File

@@ -20,8 +20,8 @@
#include "Poco/Foundation.h"
#include "Poco/Exception.h"
#include "Poco/Error.h"
#include <pthread.h>
#include <errno.h>
namespace Poco {
@@ -48,8 +48,9 @@ private:
//
inline void RWLockImpl::readLockImpl()
{
if (pthread_mutex_lock(&_mutex))
throw SystemException("cannot lock mutex");
int rc = 0;
if ((rc = pthread_mutex_lock(&_mutex)))
throw SystemException("cannot lock mutex", Error::getMessage(rc));
}
@@ -61,7 +62,7 @@ inline bool RWLockImpl::tryReadLockImpl()
else if (rc == EBUSY)
return false;
else
throw SystemException("cannot lock mutex");
throw SystemException("cannot lock mutex", Error::getMessage(rc));
}
@@ -81,8 +82,9 @@ inline bool RWLockImpl::tryWriteLockImpl()
inline void RWLockImpl::unlockImpl()
{
if (pthread_mutex_unlock(&_mutex))
throw SystemException("cannot unlock mutex");
int rc = 0;
if ((rc = pthread_mutex_unlock(&_mutex)))
throw SystemException("cannot unlock mutex", Error::getMessage(rc));
}