Commit 0ee9def4 authored by Steven Murray's avatar Steven Murray
Browse files

Made more use of castor::utils::errnoToString() and castor::utils::serrnoToString()

parent 480782bd
......@@ -27,6 +27,7 @@
#include "castor/legacymsg/RmcProxy.hpp"
#include "castor/legacymsg/RmcUnmountMsgBody.hpp"
#include "castor/utils/SmartFd.hpp"
#include "castor/utils/utils.hpp"
#include "h/rmc_constants.h"
#include "h/serrno.h"
......@@ -196,7 +197,7 @@ protected:
{
castor::exception::Exception ex;
ex.getMessage() << "Received error from rmcd: rmcRc=" << rmcRc <<
" rmcRcStr=" << sstrerror(rmcRc);
" rmcRcStr=" << utils::serrnoToString(rmcRc);
if(!rmcErrorStream.str().empty()) {
ex.getMessage() << " rmcErrorStream=" << rmcErrorStream.str();
}
......
......@@ -91,8 +91,7 @@ void castor::tape::tapeserver::daemon::ProcessForker::closeCmdReceiverSocket()
std::list<log::Param> params;
params.push_back(log::Param("cmdSocket", m_cmdSocket));
if(-1 == close(m_cmdSocket)) {
char message[100];
sstrerror_r(errno, message, sizeof(message));
const std::string message = castor::utils::errnoToString(errno);
params.push_back(log::Param("message", message));
m_log(LOG_ERR, "Failed to close command receiver socket",
params);
......@@ -164,8 +163,7 @@ bool castor::tape::tapeserver::daemon::ProcessForker::thereIsAPendingMsg() {
return false;
case -1: // Error
{
char message[100];
sstrerror_r(errno, message, sizeof(message));
const std::string message = castor::utils::errnoToString(errno);
log::Param params[] = {log::Param("message", message)};
m_log(LOG_ERR,
"Error detected when checking for a pending ProcessForker message",
......
......@@ -26,6 +26,7 @@
#include "castor/messages/StopProcessForker.pb.h"
#include "castor/tape/tapeserver/daemon/ProcessForkerProxySocket.hpp"
#include "castor/tape/tapeserver/daemon/ProcessForkerUtils.hpp"
#include "castor/utils/utils.hpp"
#include "h/serrno.h"
#include <errno.h>
......@@ -45,8 +46,7 @@ castor::tape::tapeserver::daemon::ProcessForkerProxySocket::
castor::tape::tapeserver::daemon::ProcessForkerProxySocket::
~ProcessForkerProxySocket() throw() {
if(-1 == close(m_socketFd)) {
char message[100];
sstrerror_r(errno, message, sizeof(message));
const std::string message = castor::utils::errnoToString(errno);
log::Param params[] = {log::Param("socketFd", m_socketFd),
log::Param("message", message)};
m_log(LOG_ERR,
......
......@@ -25,6 +25,7 @@
#include "castor/io/io.hpp"
#include "castor/tape/tapeserver/daemon/ProcessForkerUtils.hpp"
#include "castor/utils/SmartArrayPtr.hpp"
#include "castor/utils/utils.hpp"
#include "h/serrno.h"
#include <errno.h>
......@@ -287,8 +288,7 @@ void castor::tape::tapeserver::daemon::ProcessForkerUtils::
const ssize_t writeRc = write(fd, &value, sizeof(value));
if(-1 == writeRc) {
char message[100];
sstrerror_r(errno, message, sizeof(message));
const std::string message = castor::utils::errnoToString(errno);
castor::exception::Exception ex;
ex.getMessage() << "Failed to write uint32_t: " << message;
throw ex;
......@@ -370,8 +370,7 @@ void castor::tape::tapeserver::daemon::ProcessForkerUtils::
const ssize_t writeRc = write(fd, str.c_str(), str.length());
if(-1 == writeRc) {
char message[100];
sstrerror_r(errno, message, sizeof(message));
const std::string message = castor::utils::errnoToString(errno);
castor::exception::Exception ex;
ex.getMessage() << "Failed to write string: " << message;
throw ex;
......
......@@ -115,8 +115,7 @@ const char *castor::tape::tapeserver::daemon::TapeDaemon::stateToStr(
std::string castor::tape::tapeserver::daemon::TapeDaemon::getHostName() const {
char nameBuf[81];
if(gethostname(nameBuf, sizeof(nameBuf))) {
char message[100];
sstrerror_r(errno, message, sizeof(message));
const std::string message = castor::utils::errnoToString(errno);
castor::exception::Exception ex;
ex.getMessage() << "Failed to get host name: " << message;
throw ex;
......@@ -149,8 +148,7 @@ castor::tape::tapeserver::daemon::TapeDaemon::~TapeDaemon() throw() {
void castor::tape::tapeserver::daemon::TapeDaemon::destroyZmqContext() throw() {
if(NULL != m_zmqContext) {
if(zmq_term(m_zmqContext)) {
char message[100];
sstrerror_r(errno, message, sizeof(message));
const std::string message = castor::utils::errnoToString(errno);
castor::log::Param params[] = {castor::log::Param("message", message)};
m_log(LOG_ERR, "Failed to destroy ZMQ context", params);
} else {
......@@ -314,8 +312,7 @@ pid_t castor::tape::tapeserver::daemon::TapeDaemon::forkProcessForker(
// If fork failed
if(0 > forkRc) {
char message[100];
sstrerror_r(errno, message, sizeof(message));
const std::string message = castor::utils::errnoToString(errno);
closeForkerCmdPair(cmdPair);
closeForkerReaperPair(reaperPair);
......@@ -429,8 +426,7 @@ std::pair<int, int>
void castor::tape::tapeserver::daemon::TapeDaemon::closeForkerCmdPair(
const ForkerCmdPair &cmdPair) const {
if(close(cmdPair.tapeDaemon)) {
char message[100];
sstrerror_r(errno, message, sizeof(message));
const std::string message = castor::utils::errnoToString(errno);
castor::exception::Exception ex;
ex.getMessage() << "Failed to close TapeDaemon side of cmdPair"
": cmdPair.tapeDaemon=" << cmdPair.tapeDaemon << ": " << message;
......@@ -438,8 +434,7 @@ void castor::tape::tapeserver::daemon::TapeDaemon::closeForkerCmdPair(
}
if(close(cmdPair.processForker)) {
char message[100];
sstrerror_r(errno, message, sizeof(message));
const std::string message = castor::utils::errnoToString(errno);
castor::exception::Exception ex;
ex.getMessage() << "Failed to close ProcessForker side of cmdPair"
": cmdPair.processForker=" << cmdPair.processForker << ": " << message;
......@@ -453,8 +448,7 @@ void castor::tape::tapeserver::daemon::TapeDaemon::closeForkerCmdPair(
void castor::tape::tapeserver::daemon::TapeDaemon::closeForkerReaperPair(
const ForkerReaperPair &reaperPair) const {
if(close(reaperPair.tapeDaemon)) {
char message[100];
sstrerror_r(errno, message, sizeof(message));
const std::string message = castor::utils::errnoToString(errno);
castor::exception::Exception ex;
ex.getMessage() << "Failed to close TapeDaemon side of reaperPair"
": reaperPair.tapeDaemon=" << reaperPair.tapeDaemon << ": " << message;
......@@ -462,8 +456,7 @@ void castor::tape::tapeserver::daemon::TapeDaemon::closeForkerReaperPair(
}
if(close(reaperPair.processForker)) {
char message[100];
sstrerror_r(errno, message, sizeof(message));
const std::string message = castor::utils::errnoToString(errno);
castor::exception::Exception ex;
ex.getMessage() << "Failed to close ProcessForker side of reaperPair"
": reaperPair.processForker=" << reaperPair.processForker << ": " <<
......@@ -478,8 +471,7 @@ void castor::tape::tapeserver::daemon::TapeDaemon::closeForkerReaperPair(
void castor::tape::tapeserver::daemon::TapeDaemon::
closeProcessForkerSideOfCmdPair(const ForkerCmdPair &cmdPair) const {
if(close(cmdPair.processForker)) {
char message[100];
sstrerror_r(errno, message, sizeof(message));
const std::string message = castor::utils::errnoToString(errno);
castor::exception::Exception ex;
ex.getMessage() << "TapeDaemon parent process failed to close"
" ProcessForker side of cmdPair: cmdPair.processForker=" <<
......@@ -495,8 +487,7 @@ void castor::tape::tapeserver::daemon::TapeDaemon::
closeProcessForkerSideOfReaperPair(const ForkerReaperPair &reaperPair)
const {
if(close(reaperPair.processForker)) {
char message[100];
sstrerror_r(errno, message, sizeof(message));
const std::string message = castor::utils::errnoToString(errno);
castor::exception::Exception ex;
ex.getMessage() << "TapeDaemon parent process failed to close"
" ProcessForker side of reaperPair: reaperPair.processForker=" <<
......@@ -511,8 +502,7 @@ void castor::tape::tapeserver::daemon::TapeDaemon::
void castor::tape::tapeserver::daemon::TapeDaemon::
closeTapeDaemonSideOfCmdPair(const ForkerCmdPair &cmdPair) const {
if(close(cmdPair.tapeDaemon)) {
char message[100];
sstrerror_r(errno, message, sizeof(message));
const std::string message = castor::utils::errnoToString(errno);
castor::exception::Exception ex;
ex.getMessage() << "ProcessForker process failed to close"
" TapeDaemon side of cmdPair: cmdPair.tapeDaemon=" << cmdPair.tapeDaemon
......@@ -527,8 +517,7 @@ void castor::tape::tapeserver::daemon::TapeDaemon::
void castor::tape::tapeserver::daemon::TapeDaemon::
closeTapeDaemonSideOfReaperPair(const ForkerReaperPair &reaperPair) const {
if(close(reaperPair.tapeDaemon)) {
char message[100];
sstrerror_r(errno, message, sizeof(message));
const std::string message = castor::utils::errnoToString(errno);
castor::exception::Exception ex;
ex.getMessage() << "ProcessForker process failed to close"
" TapeDaemon side of reaperPair: reaperPair.tapeDaemon=" <<
......@@ -641,8 +630,7 @@ void castor::tape::tapeserver::daemon::TapeDaemon::initZmqContext() {
const int sizeOfIOThreadPoolForZMQ = 1;
m_zmqContext = zmq_init(sizeOfIOThreadPoolForZMQ);
if(NULL == m_zmqContext) {
char message[100];
sstrerror_r(errno, message, sizeof(message));
const std::string message = castor::utils::errnoToString(errno);
castor::exception::Exception ex;
ex.getMessage() << "Failed to instantiate ZMQ context: " << message;
throw ex;
......
......@@ -49,7 +49,7 @@ castor::tape::tapeserver::daemon::TpconfigLines castor::tape::tapeserver::
"Failed to parse TPCONFIG file"
": Failed to open file"
": filename='" << filename << "'"
": " << sstrerror(savedErrno);
": " << castor::utils::errnoToString(savedErrno);
throw ex;
}
......@@ -161,7 +161,7 @@ castor::tape::tapeserver::daemon::TpconfigLines castor::tape::tapeserver::
"Failed to parse TPCONFIG file"
": Failed to read file"
": filename='" << filename << "'"
": " << sstrerror(fgetsErrno);
": " << castor::utils::errnoToString(fgetsErrno);
throw ex;
}
......
......@@ -20,6 +20,7 @@
*****************************************************************************/
#include "castor/tape/tapeserver/daemon/VdqmConnectionHandler.hpp"
#include "castor/utils/utils.hpp"
#include "h/common.h"
#include "h/serrno.h"
......@@ -148,9 +149,9 @@ bool castor::tape::tapeserver::daemon::VdqmConnectionHandler::connectionIsAuthor
const int savedSerrno = serrno;
std::string errorMessage;
if(0 != serrno) {
errorMessage = sstrerror(savedSerrno);
errorMessage = castor::utils::serrnoToString(savedSerrno);
} else if(0 != errno) {
errorMessage = sstrerror(savedErrno);
errorMessage = castor::utils::errnoToString(savedErrno);
} else {
errorMessage = "UNKNOWN";
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment