mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-13 00:31:14 +00:00
Fix Coverity issues
This commit is contained in:
parent
2656d8098c
commit
4db91a52eb
|
@ -14,6 +14,8 @@
|
||||||
|
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
|
#include <boost/exception/all.hpp>
|
||||||
|
|
||||||
#include "FairMQChannel.h"
|
#include "FairMQChannel.h"
|
||||||
#include "FairMQLogger.h"
|
#include "FairMQLogger.h"
|
||||||
|
|
||||||
|
@ -49,139 +51,237 @@ FairMQChannel::FairMQChannel(const string& type, const string& method, const str
|
||||||
|
|
||||||
std::string FairMQChannel::GetType()
|
std::string FairMQChannel::GetType()
|
||||||
{
|
{
|
||||||
boost::unique_lock<boost::mutex> scoped_lock(channelMutex);
|
try
|
||||||
return fType;
|
{
|
||||||
|
boost::unique_lock<boost::mutex> scoped_lock(channelMutex);
|
||||||
|
return fType;
|
||||||
|
}
|
||||||
|
catch (boost::exception& e)
|
||||||
|
{
|
||||||
|
LOG(ERROR) << boost::diagnostic_information(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string FairMQChannel::GetMethod()
|
std::string FairMQChannel::GetMethod()
|
||||||
{
|
{
|
||||||
boost::unique_lock<boost::mutex> scoped_lock(channelMutex);
|
try
|
||||||
return fMethod;
|
{
|
||||||
|
boost::unique_lock<boost::mutex> scoped_lock(channelMutex);
|
||||||
|
return fMethod;
|
||||||
|
}
|
||||||
|
catch (boost::exception& e)
|
||||||
|
{
|
||||||
|
LOG(ERROR) << boost::diagnostic_information(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string FairMQChannel::GetAddress()
|
std::string FairMQChannel::GetAddress()
|
||||||
{
|
{
|
||||||
boost::unique_lock<boost::mutex> scoped_lock(channelMutex);
|
try
|
||||||
return fAddress;
|
{
|
||||||
|
boost::unique_lock<boost::mutex> scoped_lock(channelMutex);
|
||||||
|
return fAddress;
|
||||||
|
}
|
||||||
|
catch (boost::exception& e)
|
||||||
|
{
|
||||||
|
LOG(ERROR) << boost::diagnostic_information(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int FairMQChannel::GetSndBufSize()
|
int FairMQChannel::GetSndBufSize()
|
||||||
{
|
{
|
||||||
boost::unique_lock<boost::mutex> scoped_lock(channelMutex);
|
try
|
||||||
return fSndBufSize;
|
{
|
||||||
|
boost::unique_lock<boost::mutex> scoped_lock(channelMutex);
|
||||||
|
return fSndBufSize;
|
||||||
|
}
|
||||||
|
catch (boost::exception& e)
|
||||||
|
{
|
||||||
|
LOG(ERROR) << boost::diagnostic_information(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int FairMQChannel::GetRcvBufSize()
|
int FairMQChannel::GetRcvBufSize()
|
||||||
{
|
{
|
||||||
boost::unique_lock<boost::mutex> scoped_lock(channelMutex);
|
try
|
||||||
return fRcvBufSize;
|
{
|
||||||
|
boost::unique_lock<boost::mutex> scoped_lock(channelMutex);
|
||||||
|
return fRcvBufSize;
|
||||||
|
}
|
||||||
|
catch (boost::exception& e)
|
||||||
|
{
|
||||||
|
LOG(ERROR) << boost::diagnostic_information(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int FairMQChannel::GetRateLogging()
|
int FairMQChannel::GetRateLogging()
|
||||||
{
|
{
|
||||||
boost::unique_lock<boost::mutex> scoped_lock(channelMutex);
|
try
|
||||||
return fRateLogging;
|
{
|
||||||
|
boost::unique_lock<boost::mutex> scoped_lock(channelMutex);
|
||||||
|
return fRateLogging;
|
||||||
|
}
|
||||||
|
catch (boost::exception& e)
|
||||||
|
{
|
||||||
|
LOG(ERROR) << boost::diagnostic_information(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FairMQChannel::UpdateType(const std::string& type)
|
void FairMQChannel::UpdateType(const std::string& type)
|
||||||
{
|
{
|
||||||
boost::unique_lock<boost::mutex> scoped_lock(channelMutex);
|
try
|
||||||
fType = type;
|
{
|
||||||
|
boost::unique_lock<boost::mutex> scoped_lock(channelMutex);
|
||||||
|
fType = type;
|
||||||
|
}
|
||||||
|
catch (boost::exception& e)
|
||||||
|
{
|
||||||
|
LOG(ERROR) << boost::diagnostic_information(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
void FairMQChannel::UpdateMethod(const std::string& method)
|
void FairMQChannel::UpdateMethod(const std::string& method)
|
||||||
{
|
{
|
||||||
boost::unique_lock<boost::mutex> scoped_lock(channelMutex);
|
try
|
||||||
fMethod = method;
|
{
|
||||||
|
boost::unique_lock<boost::mutex> scoped_lock(channelMutex);
|
||||||
|
fMethod = method;
|
||||||
|
}
|
||||||
|
catch (boost::exception& e)
|
||||||
|
{
|
||||||
|
LOG(ERROR) << boost::diagnostic_information(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
void FairMQChannel::UpdateAddress(const std::string& address)
|
void FairMQChannel::UpdateAddress(const std::string& address)
|
||||||
{
|
{
|
||||||
boost::unique_lock<boost::mutex> scoped_lock(channelMutex);
|
try
|
||||||
fAddress = address;
|
{
|
||||||
|
boost::unique_lock<boost::mutex> scoped_lock(channelMutex);
|
||||||
|
fAddress = address;
|
||||||
|
}
|
||||||
|
catch (boost::exception& e)
|
||||||
|
{
|
||||||
|
LOG(ERROR) << boost::diagnostic_information(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
void FairMQChannel::UpdateSndBufSize(const int sndBufSize)
|
void FairMQChannel::UpdateSndBufSize(const int sndBufSize)
|
||||||
{
|
{
|
||||||
boost::unique_lock<boost::mutex> scoped_lock(channelMutex);
|
try
|
||||||
fSndBufSize = sndBufSize;
|
{
|
||||||
|
boost::unique_lock<boost::mutex> scoped_lock(channelMutex);
|
||||||
|
fSndBufSize = sndBufSize;
|
||||||
|
}
|
||||||
|
catch (boost::exception& e)
|
||||||
|
{
|
||||||
|
LOG(ERROR) << boost::diagnostic_information(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
void FairMQChannel::UpdateRcvBufSize(const int rcvBufSize)
|
void FairMQChannel::UpdateRcvBufSize(const int rcvBufSize)
|
||||||
{
|
{
|
||||||
boost::unique_lock<boost::mutex> scoped_lock(channelMutex);
|
try
|
||||||
fRcvBufSize = rcvBufSize;
|
{
|
||||||
|
boost::unique_lock<boost::mutex> scoped_lock(channelMutex);
|
||||||
|
fRcvBufSize = rcvBufSize;
|
||||||
|
}
|
||||||
|
catch (boost::exception& e)
|
||||||
|
{
|
||||||
|
LOG(ERROR) << boost::diagnostic_information(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
void FairMQChannel::UpdateRateLogging(const int rateLogging)
|
void FairMQChannel::UpdateRateLogging(const int rateLogging)
|
||||||
{
|
{
|
||||||
boost::unique_lock<boost::mutex> scoped_lock(channelMutex);
|
try
|
||||||
fRateLogging = rateLogging;
|
{
|
||||||
|
boost::unique_lock<boost::mutex> scoped_lock(channelMutex);
|
||||||
|
fRateLogging = rateLogging;
|
||||||
|
}
|
||||||
|
catch (boost::exception& e)
|
||||||
|
{
|
||||||
|
LOG(ERROR) << boost::diagnostic_information(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FairMQChannel::IsValid()
|
bool FairMQChannel::IsValid()
|
||||||
{
|
{
|
||||||
boost::unique_lock<boost::mutex> scoped_lock(channelMutex);
|
try
|
||||||
return fIsValid;
|
{
|
||||||
|
boost::unique_lock<boost::mutex> scoped_lock(channelMutex);
|
||||||
|
return fIsValid;
|
||||||
|
}
|
||||||
|
catch (boost::exception& e)
|
||||||
|
{
|
||||||
|
LOG(ERROR) << boost::diagnostic_information(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FairMQChannel::ValidateChannel()
|
bool FairMQChannel::ValidateChannel()
|
||||||
{
|
{
|
||||||
boost::unique_lock<boost::mutex> scoped_lock(channelMutex);
|
try
|
||||||
|
|
||||||
stringstream ss;
|
|
||||||
ss << "Validating channel " << fChannelName << "... ";
|
|
||||||
|
|
||||||
if (fIsValid)
|
|
||||||
{
|
{
|
||||||
ss << "ALREADY VALID";
|
boost::unique_lock<boost::mutex> scoped_lock(channelMutex);
|
||||||
|
|
||||||
|
stringstream ss;
|
||||||
|
ss << "Validating channel " << fChannelName << "... ";
|
||||||
|
|
||||||
|
if (fIsValid)
|
||||||
|
{
|
||||||
|
ss << "ALREADY VALID";
|
||||||
|
LOG(DEBUG) << ss.str();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
const string socketTypeNames[] = { "sub", "pub", "pull", "push", "req", "rep", "xsub", "xpub", "dealer", "router", "pair" };
|
||||||
|
const set<string> socketTypes(socketTypeNames, socketTypeNames + sizeof(socketTypeNames) / sizeof(string));
|
||||||
|
if (socketTypes.find(fType) == socketTypes.end())
|
||||||
|
{
|
||||||
|
ss << "INVALID";
|
||||||
|
LOG(DEBUG) << ss.str();
|
||||||
|
LOG(DEBUG) << "Invalid channel type: " << fType;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const string socketMethodNames[] = { "bind", "connect" };
|
||||||
|
const set<string> socketMethods(socketMethodNames, socketMethodNames + sizeof(socketMethodNames) / sizeof(string));
|
||||||
|
if (socketMethods.find(fMethod) == socketMethods.end())
|
||||||
|
{
|
||||||
|
ss << "INVALID";
|
||||||
|
LOG(DEBUG) << ss.str();
|
||||||
|
LOG(DEBUG) << "Invalid channel method: " << fMethod;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fAddress == "unspecified" || fAddress == "")
|
||||||
|
{
|
||||||
|
ss << "INVALID";
|
||||||
|
LOG(DEBUG) << ss.str();
|
||||||
|
LOG(DEBUG) << "invalid channel address: " << fAddress;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fSndBufSize < 0)
|
||||||
|
{
|
||||||
|
ss << "INVALID";
|
||||||
|
LOG(DEBUG) << ss.str();
|
||||||
|
LOG(DEBUG) << "invalid channel send buffer size: " << fSndBufSize;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fRcvBufSize < 0)
|
||||||
|
{
|
||||||
|
ss << "INVALID";
|
||||||
|
LOG(DEBUG) << ss.str();
|
||||||
|
LOG(DEBUG) << "invalid channel receive buffer size: " << fRcvBufSize;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
fIsValid = true;
|
||||||
|
ss << "VALID";
|
||||||
LOG(DEBUG) << ss.str();
|
LOG(DEBUG) << ss.str();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
catch (boost::exception& e)
|
||||||
const string socketTypeNames[] = { "sub", "pub", "pull", "push", "req", "rep", "xsub", "xpub", "dealer", "router", "pair" };
|
|
||||||
const set<string> socketTypes(socketTypeNames, socketTypeNames + sizeof(socketTypeNames) / sizeof(string));
|
|
||||||
if (socketTypes.find(fType) == socketTypes.end())
|
|
||||||
{
|
{
|
||||||
ss << "INVALID";
|
LOG(ERROR) << boost::diagnostic_information(e);
|
||||||
LOG(DEBUG) << ss.str();
|
|
||||||
LOG(DEBUG) << "Invalid channel type: " << fType;
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const string socketMethodNames[] = { "bind", "connect" };
|
|
||||||
const set<string> socketMethods(socketMethodNames, socketMethodNames + sizeof(socketMethodNames) / sizeof(string));
|
|
||||||
if (socketMethods.find(fMethod) == socketMethods.end())
|
|
||||||
{
|
|
||||||
ss << "INVALID";
|
|
||||||
LOG(DEBUG) << ss.str();
|
|
||||||
LOG(DEBUG) << "Invalid channel method: " << fMethod;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fAddress == "unspecified" || fAddress == "")
|
|
||||||
{
|
|
||||||
ss << "INVALID";
|
|
||||||
LOG(DEBUG) << ss.str();
|
|
||||||
LOG(DEBUG) << "invalid channel address: " << fAddress;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fSndBufSize < 0)
|
|
||||||
{
|
|
||||||
ss << "INVALID";
|
|
||||||
LOG(DEBUG) << ss.str();
|
|
||||||
LOG(DEBUG) << "invalid channel send buffer size: " << fSndBufSize;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fRcvBufSize < 0)
|
|
||||||
{
|
|
||||||
ss << "INVALID";
|
|
||||||
LOG(DEBUG) << ss.str();
|
|
||||||
LOG(DEBUG) << "invalid channel receive buffer size: " << fRcvBufSize;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
fIsValid = true;
|
|
||||||
ss << "VALID";
|
|
||||||
LOG(DEBUG) << ss.str();
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FairMQChannel::ResetChannel()
|
void FairMQChannel::ResetChannel()
|
||||||
|
|
|
@ -98,7 +98,11 @@ bool FairMQStateMachine::ChangeState(int event)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (boost::exception &e)
|
catch (boost::thread_interrupted& e)
|
||||||
|
{
|
||||||
|
LOG(ERROR) << boost::diagnostic_information(e);
|
||||||
|
}
|
||||||
|
catch (boost::exception& e)
|
||||||
{
|
{
|
||||||
LOG(ERROR) << boost::diagnostic_information(e);
|
LOG(ERROR) << boost::diagnostic_information(e);
|
||||||
}
|
}
|
||||||
|
@ -121,10 +125,17 @@ void FairMQStateMachine::WaitForEndOfState(int event)
|
||||||
case RESET_TASK:
|
case RESET_TASK:
|
||||||
case RESET_DEVICE:
|
case RESET_DEVICE:
|
||||||
{
|
{
|
||||||
boost::unique_lock<boost::mutex> lock(fStateMutex);
|
try
|
||||||
while (!fStateFinished)
|
|
||||||
{
|
{
|
||||||
fStateCondition.wait(lock);
|
boost::unique_lock<boost::mutex> lock(fStateMutex);
|
||||||
|
while (!fStateFinished)
|
||||||
|
{
|
||||||
|
fStateCondition.wait(lock);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (boost::exception& e)
|
||||||
|
{
|
||||||
|
LOG(ERROR) << boost::diagnostic_information(e);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -133,7 +144,7 @@ void FairMQStateMachine::WaitForEndOfState(int event)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (boost::exception &e)
|
catch (boost::thread_interrupted& e)
|
||||||
{
|
{
|
||||||
LOG(ERROR) << boost::diagnostic_information(e);
|
LOG(ERROR) << boost::diagnostic_information(e);
|
||||||
}
|
}
|
||||||
|
@ -173,7 +184,7 @@ bool FairMQStateMachine::WaitForEndOfStateForMs(int event, int durationInMs)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (boost::exception &e)
|
catch (boost::thread_interrupted &e)
|
||||||
{
|
{
|
||||||
LOG(ERROR) << boost::diagnostic_information(e);
|
LOG(ERROR) << boost::diagnostic_information(e);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user