Commit ef42c823 authored by Victor Kotlyar's avatar Victor Kotlyar
Browse files

Renamed castor::exception::Errnum to

cta::exception::Errnum
parent 4eef892e
/******************************************************************************
*
* This file is part of the Castor project.
* See http://castor.web.cern.ch/castor
*
* Copyright (C) 2003 CERN
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*
*
*
* @author Castor Dev team, castor-dev@cern.ch
*****************************************************************************/
#include "castor/exception/Errnum.hpp"
#include "common/utils/utils.hpp"
#include <errno.h>
#include <string.h>
using namespace castor::exception;
Errnum::Errnum(std::string what):Exception("") {
m_errnum = errno;
ErrnumConstructorBottomHalf(what);
}
Errnum::Errnum(int err, std::string what):Exception("") {
m_errnum = err;
ErrnumConstructorBottomHalf(what);
}
void Errnum::ErrnumConstructorBottomHalf(const std::string & what) {
m_strerror = cta::utils::errnoToString(m_errnum);
std::stringstream w2;
if (what.size())
w2 << what << " ";
w2 << "Errno=" << m_errnum << ": " << m_strerror;
getMessage().str(w2.str());
}
void Errnum::throwOnReturnedErrno (int err, std::string context) {
if (err) throw Errnum(err, context);
}
void Errnum::throwOnNonZero(int status, std::string context) {
if (status) throw Errnum(context);
}
void Errnum::throwOnZero(int status, std::string context) {
if (!status) throw Errnum(context);
}
void Errnum::throwOnNull(void * f, std::string context) {
if (NULL == f) throw Errnum(context);
}
void Errnum::throwOnNegative(int ret, std::string context) {
if (ret < 0) throw Errnum(context);
}
void Errnum::throwOnMinusOne(int ret, std::string context) {
if (-1 == ret) throw Errnum(context);
}
/******************************************************************************
*
* This file is part of the Castor project.
* See http://castor.web.cern.ch/castor
*
* Copyright (C) 2003 CERN
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*
*
*
* @author Castor Dev team, castor-dev@cern.ch
*****************************************************************************/
#pragma once
#include "common/exception/Exception.hpp"
namespace castor {
namespace exception {
class Errnum: public cta::exception::Exception {
public:
Errnum(std::string what = "");
Errnum (int err, std::string what = "");
virtual ~Errnum() throw() {};
int errorNumber() const { return m_errnum; }
std::string strError() const { return m_strerror; }
static void throwOnReturnedErrno(int err, std::string context = "");
static void throwOnNonZero(int status, std::string context = "");
static void throwOnZero(int status, std::string context = "");
static void throwOnNull(void * f, std::string context = "");
static void throwOnNegative(int ret, std::string context = "");
static void throwOnMinusOne(int ret, std::string context = "");
protected:
void ErrnumConstructorBottomHalf(const std::string & what);
int m_errnum;
std::string m_strerror;
};
}
}
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
*****************************************************************************/ *****************************************************************************/
#include "common/exception/Exception.hpp" #include "common/exception/Exception.hpp"
#include "Errnum.hpp" #include "common/exception/Errnum.hpp"
#include <errno.h> #include <errno.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
...@@ -75,51 +75,51 @@ namespace unitTests { ...@@ -75,51 +75,51 @@ namespace unitTests {
} }
} }
TEST(castor_exceptions, errnum_throwing) { TEST(cta_exceptions, errnum_throwing) {
/* Mickey Mouse test as we had trouble which throwing Errnum (with errno=ENOENT)*/ /* Mickey Mouse test as we had trouble which throwing Errnum (with errno=ENOENT)*/
errno = ENOENT; errno = ENOENT;
try { try {
throw castor::exception::Errnum("Test ENOENT"); throw cta::exception::Errnum("Test ENOENT");
} catch (std::exception & e) { } catch (std::exception & e) {
std::string temp = e.what(); std::string temp = e.what();
temp += " "; temp += " ";
} }
} }
TEST(castor_exceptions, Errnum_throwers) { TEST(cta_exceptions, Errnum_throwers) {
/* throwOnReturnedErrno */ /* throwOnReturnedErrno */
ASSERT_NO_THROW(castor::exception::Errnum::throwOnReturnedErrno(0, "Context")); ASSERT_NO_THROW(cta::exception::Errnum::throwOnReturnedErrno(0, "Context"));
ASSERT_THROW(castor::exception::Errnum::throwOnReturnedErrno(ENOSPC, "Context"), ASSERT_THROW(cta::exception::Errnum::throwOnReturnedErrno(ENOSPC, "Context"),
castor::exception::Errnum); cta::exception::Errnum);
/* throwOnNonZero */ /* throwOnNonZero */
errno = ENOENT; errno = ENOENT;
ASSERT_NO_THROW(castor::exception::Errnum::throwOnNonZero(0, "Context")); ASSERT_NO_THROW(cta::exception::Errnum::throwOnNonZero(0, "Context"));
ASSERT_THROW(castor::exception::Errnum::throwOnNonZero(-1, "Context"), ASSERT_THROW(cta::exception::Errnum::throwOnNonZero(-1, "Context"),
castor::exception::Errnum); cta::exception::Errnum);
/* throwOnMinusOne */ /* throwOnMinusOne */
errno = ENOENT; errno = ENOENT;
ASSERT_NO_THROW(castor::exception::Errnum::throwOnMinusOne(0, "Context")); ASSERT_NO_THROW(cta::exception::Errnum::throwOnMinusOne(0, "Context"));
ASSERT_THROW(castor::exception::Errnum::throwOnMinusOne(-1, "Context"), ASSERT_THROW(cta::exception::Errnum::throwOnMinusOne(-1, "Context"),
castor::exception::Errnum); cta::exception::Errnum);
/* throwOnNegative */ /* throwOnNegative */
errno = ENOENT; errno = ENOENT;
ASSERT_NO_THROW(castor::exception::Errnum::throwOnNegative(0, "Context")); ASSERT_NO_THROW(cta::exception::Errnum::throwOnNegative(0, "Context"));
ASSERT_THROW(castor::exception::Errnum::throwOnNegative(-1, "Context"), ASSERT_THROW(cta::exception::Errnum::throwOnNegative(-1, "Context"),
castor::exception::Errnum); cta::exception::Errnum);
/* throwOnNull */ /* throwOnNull */
errno = ENOENT; errno = ENOENT;
ASSERT_NO_THROW(castor::exception::Errnum::throwOnNull(this, "Context")); ASSERT_NO_THROW(cta::exception::Errnum::throwOnNull(this, "Context"));
ASSERT_THROW(castor::exception::Errnum::throwOnNull(NULL, "Context"), ASSERT_THROW(cta::exception::Errnum::throwOnNull(NULL, "Context"),
castor::exception::Errnum); cta::exception::Errnum);
/* throwOnZero */ /* throwOnZero */
errno = ENOENT; errno = ENOENT;
ASSERT_NO_THROW(castor::exception::Errnum::throwOnZero(1, "Context")); ASSERT_NO_THROW(cta::exception::Errnum::throwOnZero(1, "Context"));
ASSERT_THROW(castor::exception::Errnum::throwOnZero(0, "Context"), ASSERT_THROW(cta::exception::Errnum::throwOnZero(0, "Context"),
castor::exception::Errnum); cta::exception::Errnum);
} }
} }
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#include "castor/io/io.hpp" #include "castor/io/io.hpp"
#include "castor/utils/SmartFd.hpp" #include "castor/utils/SmartFd.hpp"
#include "castor/io/marshall.h" #include "castor/io/marshall.h"
#include "castor/exception/Errnum.hpp" #include "common/exception/Errnum.hpp"
#include <fcntl.h> #include <fcntl.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
...@@ -82,7 +82,7 @@ protected: ...@@ -82,7 +82,7 @@ protected:
strncpy(listenAddr.sun_path, listenSockPath, strncpy(listenAddr.sun_path, listenSockPath,
sizeof(listenAddr.sun_path) - 1); sizeof(listenAddr.sun_path) - 1);
castor::exception::Errnum::throwOnNonZero( cta::exception::Errnum::throwOnNonZero(
bind(smartListenSock.get(), (const struct sockaddr *)&listenAddr, bind(smartListenSock.get(), (const struct sockaddr *)&listenAddr,
sizeof(listenAddr)), "Call to bind() failed: "); sizeof(listenAddr)), "Call to bind() failed: ");
} }
......
#include "castor/messages/Mutex.hpp" #include "castor/messages/Mutex.hpp"
#include "castor/exception/Errnum.hpp" #include "common/exception/Errnum.hpp"
#include "common/exception/Exception.hpp" #include "common/exception/Exception.hpp"
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
...@@ -7,17 +7,17 @@ ...@@ -7,17 +7,17 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
castor::messages::Mutex::Mutex() { castor::messages::Mutex::Mutex() {
pthread_mutexattr_t attr; pthread_mutexattr_t attr;
castor::exception::Errnum::throwOnReturnedErrno( cta::exception::Errnum::throwOnReturnedErrno(
pthread_mutexattr_init(&attr), pthread_mutexattr_init(&attr),
"Error from pthread_mutexattr_init in castor::messages::Mutex::Mutex()"); "Error from pthread_mutexattr_init in castor::messages::Mutex::Mutex()");
castor::exception::Errnum::throwOnReturnedErrno( cta::exception::Errnum::throwOnReturnedErrno(
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK), pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK),
"Error from pthread_mutexattr_settype in castor::messages::Mutex::Mutex()"); "Error from pthread_mutexattr_settype in castor::messages::Mutex::Mutex()");
castor::exception::Errnum::throwOnReturnedErrno( cta::exception::Errnum::throwOnReturnedErrno(
pthread_mutex_init(&m_mutex, &attr), pthread_mutex_init(&m_mutex, &attr),
"Error from pthread_mutex_init in castor::messages::Mutex::Mutex()"); "Error from pthread_mutex_init in castor::messages::Mutex::Mutex()");
try { try {
castor::exception::Errnum::throwOnReturnedErrno( cta::exception::Errnum::throwOnReturnedErrno(
pthread_mutexattr_destroy(&attr), pthread_mutexattr_destroy(&attr),
"Error from pthread_mutexattr_destroy in" "Error from pthread_mutexattr_destroy in"
" castor::messages::Mutex::Mutex()"); " castor::messages::Mutex::Mutex()");
...@@ -38,7 +38,7 @@ castor::messages::Mutex::~Mutex() throw() { ...@@ -38,7 +38,7 @@ castor::messages::Mutex::~Mutex() throw() {
// lock // lock
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void castor::messages::Mutex::lock() { void castor::messages::Mutex::lock() {
castor::exception::Errnum::throwOnReturnedErrno( cta::exception::Errnum::throwOnReturnedErrno(
pthread_mutex_lock(&m_mutex), pthread_mutex_lock(&m_mutex),
"Error from pthread_mutex_lock in castor::messages::Mutex::lock()"); "Error from pthread_mutex_lock in castor::messages::Mutex::lock()");
} }
...@@ -47,7 +47,7 @@ void castor::messages::Mutex::lock() { ...@@ -47,7 +47,7 @@ void castor::messages::Mutex::lock() {
// unlock // unlock
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void castor::messages::Mutex::unlock() { void castor::messages::Mutex::unlock() {
castor::exception::Errnum::throwOnReturnedErrno( cta::exception::Errnum::throwOnReturnedErrno(
pthread_mutex_unlock(&m_mutex), pthread_mutex_unlock(&m_mutex),
"Error from pthread_mutex_unlock in castor::messages::Mutex::unlock()"); "Error from pthread_mutex_unlock in castor::messages::Mutex::unlock()");
} }
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
* @author Castor Dev team, castor-dev@cern.ch * @author Castor Dev team, castor-dev@cern.ch
*****************************************************************************/ *****************************************************************************/
#include "castor/exception/Errnum.hpp" #include "common/exception/Errnum.hpp"
#include "castor/messages/MutexLocker.hpp" #include "castor/messages/MutexLocker.hpp"
#include <gtest/gtest.h> #include <gtest/gtest.h>
...@@ -46,7 +46,7 @@ TEST(castor_messages_MutexLockerTest, ...@@ -46,7 +46,7 @@ TEST(castor_messages_MutexLockerTest,
{ {
MutexLocker ml(&m); MutexLocker ml(&m);
// This is a different flavour of duplicate locking // This is a different flavour of duplicate locking
ASSERT_THROW(m.lock(),castor::exception::Errnum); ASSERT_THROW(m.lock(),cta::exception::Errnum);
ASSERT_NO_THROW(m.unlock()); ASSERT_NO_THROW(m.unlock());
ASSERT_NO_THROW(m.lock()); ASSERT_NO_THROW(m.lock());
} }
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
* @author Castor Dev team, castor-dev@cern.ch * @author Castor Dev team, castor-dev@cern.ch
*****************************************************************************/ *****************************************************************************/
#include "castor/exception/Errnum.hpp" #include "common/exception/Errnum.hpp"
#include "castor/messages/Mutex.hpp" #include "castor/messages/Mutex.hpp"
#include <gtest/gtest.h> #include <gtest/gtest.h>
...@@ -46,11 +46,11 @@ TEST(castor_messages_MutexTest, Mutex_properly_throws_exceptions) { ...@@ -46,11 +46,11 @@ TEST(castor_messages_MutexTest, Mutex_properly_throws_exceptions) {
ASSERT_NO_THROW(m.lock()); ASSERT_NO_THROW(m.lock());
// Duplicate lock // Duplicate lock
ASSERT_THROW(m.lock(),castor::exception::Errnum); ASSERT_THROW(m.lock(),cta::exception::Errnum);
ASSERT_NO_THROW(m.unlock()); ASSERT_NO_THROW(m.unlock());
// Duplicate release // Duplicate release
ASSERT_THROW(m.unlock(),castor::exception::Errnum); ASSERT_THROW(m.unlock(),cta::exception::Errnum);
} }
} // namespace unitTests } // namespace unitTests
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
*****************************************************************************/ *****************************************************************************/
#pragma once #pragma once
#include "castor/exception/Errnum.hpp" #include "common/exception/Errnum.hpp"
#include "common/exception/Exception.hpp" #include "common/exception/Exception.hpp"
#include <unistd.h> #include <unistd.h>
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
* @author Castor Dev team, castor-dev@cern.ch * @author Castor Dev team, castor-dev@cern.ch
******************************************************************************/ ******************************************************************************/
#include "castor/exception/Errnum.hpp" #include "common/exception/Errnum.hpp"
#include "castor/server/Daemon.hpp" #include "castor/server/Daemon.hpp"
#include "castor/server/ThreadNotification.hpp" #include "castor/server/ThreadNotification.hpp"
#include "castor/System.hpp" #include "castor/System.hpp"
...@@ -163,7 +163,7 @@ void castor::server::Daemon::daemonizeIfNotRunInForeground( ...@@ -163,7 +163,7 @@ void castor::server::Daemon::daemonizeIfNotRunInForeground(
{ {
pid_t pid = 0; pid_t pid = 0;
castor::exception::Errnum::throwOnNegative(pid = fork(), cta::exception::Errnum::throwOnNegative(pid = fork(),
"Failed to daemonize: Failed to fork"); "Failed to daemonize: Failed to fork");
// If we got a good PID, then we can exit the parent process // If we got a good PID, then we can exit the parent process
if (0 < pid) { if (0 < pid) {
...@@ -179,17 +179,17 @@ void castor::server::Daemon::daemonizeIfNotRunInForeground( ...@@ -179,17 +179,17 @@ void castor::server::Daemon::daemonizeIfNotRunInForeground(
umask(0); umask(0);
// Run the daemon in a new session // Run the daemon in a new session
castor::exception::Errnum::throwOnNegative(setsid(), cta::exception::Errnum::throwOnNegative(setsid(),
"Failed to daemonize: Failed to run daemon is a new session"); "Failed to daemonize: Failed to run daemon is a new session");
// Redirect standard files to /dev/null // Redirect standard files to /dev/null
castor::exception::Errnum::throwOnNull( cta::exception::Errnum::throwOnNull(
freopen("/dev/null", "r", stdin), freopen("/dev/null", "r", stdin),
"Failed to daemonize: Falied to freopen stdin"); "Failed to daemonize: Falied to freopen stdin");
castor::exception::Errnum::throwOnNull( cta::exception::Errnum::throwOnNull(
freopen("/dev/null", "w", stdout), freopen("/dev/null", "w", stdout),
"Failed to daemonize: Failed to freopen stdout"); "Failed to daemonize: Failed to freopen stdout");
castor::exception::Errnum::throwOnNull( cta::exception::Errnum::throwOnNull(
freopen("/dev/null", "w", stderr), freopen("/dev/null", "w", stderr),
"Failed to daemonize: Failed to freopen stderr"); "Failed to daemonize: Failed to freopen stderr");
} // if (!m_foreground) } // if (!m_foreground)
......
#include "castor/server/Mutex.hpp" #include "castor/server/Mutex.hpp"
#include "castor/exception/Errnum.hpp" #include "common/exception/Errnum.hpp"
#include "common/exception/Exception.hpp" #include "common/exception/Exception.hpp"
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
...@@ -7,17 +7,17 @@ ...@@ -7,17 +7,17 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
castor::server::Mutex::Mutex() { castor::server::Mutex::Mutex() {
pthread_mutexattr_t attr; pthread_mutexattr_t attr;
castor::exception::Errnum::throwOnReturnedErrno( cta::exception::Errnum::throwOnReturnedErrno(
pthread_mutexattr_init(&attr), pthread_mutexattr_init(&attr),
"Error from pthread_mutexattr_init in castor::server::Mutex::Mutex()"); "Error from pthread_mutexattr_init in castor::server::Mutex::Mutex()");
castor::exception::Errnum::throwOnReturnedErrno( cta::exception::Errnum::throwOnReturnedErrno(
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK), pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK),
"Error from pthread_mutexattr_settype in castor::server::Mutex::Mutex()"); "Error from pthread_mutexattr_settype in castor::server::Mutex::Mutex()");
castor::exception::Errnum::throwOnReturnedErrno( cta::exception::Errnum::throwOnReturnedErrno(
pthread_mutex_init(&m_mutex, &attr), pthread_mutex_init(&m_mutex, &attr),
"Error from pthread_mutex_init in castor::server::Mutex::Mutex()"); "Error from pthread_mutex_init in castor::server::Mutex::Mutex()");
try { try {
castor::exception::Errnum::throwOnReturnedErrno( cta::exception::Errnum::throwOnReturnedErrno(
pthread_mutexattr_destroy(&attr), pthread_mutexattr_destroy(&attr),
"Error from pthread_mutexattr_destroy in castor::server::Mutex::Mutex()"); "Error from pthread_mutexattr_destroy in castor::server::Mutex::Mutex()");
} catch (...) { } catch (...) {
...@@ -35,7 +35,7 @@ castor::server::Mutex::~Mutex() { ...@@ -35,7 +35,7 @@ castor::server::Mutex::~Mutex() {
//lock //lock
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void castor::server::Mutex::lock() { void castor::server::Mutex::lock() {
castor::exception::Errnum::throwOnReturnedErrno( cta::exception::Errnum::throwOnReturnedErrno(
pthread_mutex_lock(&m_mutex), pthread_mutex_lock(&m_mutex),
"Error from pthread_mutex_lock in castor::server::Mutex::lock()"); "Error from pthread_mutex_lock in castor::server::Mutex::lock()");
} }
...@@ -43,7 +43,7 @@ void castor::server::Mutex::lock() { ...@@ -43,7 +43,7 @@ void castor::server::Mutex::lock() {
//unlock //unlock
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void castor::server::Mutex::unlock() { void castor::server::Mutex::unlock() {
castor::exception::Errnum::throwOnReturnedErrno( cta::exception::Errnum::throwOnReturnedErrno(
pthread_mutex_unlock(&m_mutex), pthread_mutex_unlock(&m_mutex),
"Error from pthread_mutex_unlock in castor::server::Mutex::unlock()"); "Error from pthread_mutex_unlock in castor::server::Mutex::unlock()");
} }
#include "castor/server/MutexLocker.hpp" #include "castor/server/MutexLocker.hpp"
#include "castor/server/Semaphores.hpp" #include "castor/server/Semaphores.hpp"
#include "castor/server/Threading.hpp" #include "castor/server/Threading.hpp"
#include "castor/exception/Errnum.hpp" #include "common/exception/Errnum.hpp"
#include "common/exception/Exception.hpp" #include "common/exception/Exception.hpp"
#include <errno.h> #include <errno.h>
#include <sys/time.h> #include <sys/time.h>
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
castor::server::PosixSemaphore::PosixSemaphore(int initial) castor::server::PosixSemaphore::PosixSemaphore(int initial)
{ {
castor::exception::Errnum::throwOnReturnedErrno( cta::exception::Errnum::throwOnReturnedErrno(
sem_init(&m_sem, 0, initial), sem_init(&m_sem, 0, initial),
"Error from sem_init in castor::server::PosixSemaphore::PosixSemaphore()"); "Error from sem_init in castor::server::PosixSemaphore::PosixSemaphore()");
} }
...@@ -34,7 +34,7 @@ void castor::server::PosixSemaphore::acquire() ...@@ -34,7 +34,7 @@ void castor::server::PosixSemaphore::acquire()
/* If we receive EINTR, we should just keep trying (signal interruption) */ /* If we receive EINTR, we should just keep trying (signal interruption) */
while((ret = sem_wait(&m_sem)) && EINTR == errno) {} while((ret = sem_wait(&m_sem)) && EINTR == errno) {}
/* If it was not EINTR, it's a failure */ /* If it was not EINTR, it's a failure */
castor::exception::Errnum::throwOnNonZero(ret, cta::exception::Errnum::throwOnNonZero(ret,
"Error from sem_wait in castor::server::PosixSemaphore::acquire()"); "Error from sem_wait in castor::server::PosixSemaphore::acquire()");
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
...@@ -57,7 +57,7 @@ void castor::server::PosixSemaphore::acquireWithTimeout(uint64_t timeout_us) ...@@ -57,7 +57,7 @@ void castor::server::PosixSemaphore::acquireWithTimeout(uint64_t timeout_us)
/* If we got a timeout, throw a special exception */ /* If we got a timeout, throw a special exception */
if (ret && ETIMEDOUT == errno) { throw Timeout(); } if (ret && ETIMEDOUT == errno) { throw Timeout(); }
/* If it was not EINTR, it's a failure */ /* If it was not EINTR, it's a failure */
castor::exception::Errnum::throwOnNonZero(ret, cta::exception::Errnum::throwOnNonZero(ret,
"Error from sem_wait in castor::server::PosixSemaphore::acquireWithTimeout()"); "Error from sem_wait in castor::server::PosixSemaphore::acquireWithTimeout()");
} }
...@@ -69,7 +69,7 @@ bool castor::server::PosixSemaphore::tryAcquire() ...@@ -69,7 +69,7 @@ bool castor::server::PosixSemaphore::tryAcquire()
int ret = sem_trywait(&m_sem); int ret = sem_trywait(&m_sem);
if (!ret) return true; if (!ret) return true;
if (ret && EAGAIN == errno) return false; if (ret && EAGAIN == errno) return false;
castor::exception::Errnum::throwOnNonZero(ret, cta::exception::Errnum::throwOnNonZero(ret,
"Error from sem_trywait in castor::server::PosixSemaphore::tryAcquire()"); "Error from sem_trywait in castor::server::PosixSemaphore::tryAcquire()");
/* unreacheable, just for compiler happiness */ /* unreacheable, just for compiler happiness */
return false; return false;
...@@ -81,7 +81,7 @@ void castor::server::PosixSemaphore::release(int n) ...@@ -81,7 +81,7 @@ void castor::server::PosixSemaphore::release(int n)
{ {