mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-16 01:51:45 +00:00
Fix issues found by Codacy
This commit is contained in:
committed by
Dennis Klein
parent
985150437a
commit
e1f555bc05
@@ -68,10 +68,9 @@ FairMQPollerSHM::FairMQPollerSHM(const unordered_map<string, vector<FairMQChanne
|
||||
, fNumItems(0)
|
||||
, fOffsetMap()
|
||||
{
|
||||
int offset = 0;
|
||||
|
||||
try
|
||||
{
|
||||
int offset = 0;
|
||||
// calculate offsets and the total size of the poll item set
|
||||
for (string channel : channelList)
|
||||
{
|
||||
@@ -189,7 +188,7 @@ bool FairMQPollerSHM::CheckOutput(const int index)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool FairMQPollerSHM::CheckInput(const string channelKey, const int index)
|
||||
bool FairMQPollerSHM::CheckInput(const string& channelKey, const int index)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -208,7 +207,7 @@ bool FairMQPollerSHM::CheckInput(const string channelKey, const int index)
|
||||
}
|
||||
}
|
||||
|
||||
bool FairMQPollerSHM::CheckOutput(const string channelKey, const int index)
|
||||
bool FairMQPollerSHM::CheckOutput(const string& channelKey, const int index)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@@ -37,8 +37,8 @@ class FairMQPollerSHM : public FairMQPoller
|
||||
void Poll(const int timeout) override;
|
||||
bool CheckInput(const int index) override;
|
||||
bool CheckOutput(const int index) override;
|
||||
bool CheckInput(const std::string channelKey, const int index) override;
|
||||
bool CheckOutput(const std::string channelKey, const int index) override;
|
||||
bool CheckInput(const std::string& channelKey, const int index) override;
|
||||
bool CheckOutput(const std::string& channelKey, const int index) override;
|
||||
|
||||
~FairMQPollerSHM() override;
|
||||
|
||||
|
@@ -121,12 +121,11 @@ int64_t FairMQSocketSHM::TryReceive(vector<unique_ptr<FairMQMessage>>& msgVec) {
|
||||
|
||||
int FairMQSocketSHM::SendImpl(FairMQMessagePtr& msg, const int flags, const int timeout)
|
||||
{
|
||||
int nbytes = -1;
|
||||
int elapsed = 0;
|
||||
|
||||
while (true && !fInterrupted)
|
||||
{
|
||||
nbytes = zmq_msg_send(static_cast<FairMQMessageSHM*>(msg.get())->GetMessage(), fSocket, flags);
|
||||
int nbytes = zmq_msg_send(static_cast<FairMQMessageSHM*>(msg.get())->GetMessage(), fSocket, flags);
|
||||
if (nbytes == 0)
|
||||
{
|
||||
return nbytes;
|
||||
@@ -177,13 +176,12 @@ int FairMQSocketSHM::SendImpl(FairMQMessagePtr& msg, const int flags, const int
|
||||
|
||||
int FairMQSocketSHM::ReceiveImpl(FairMQMessagePtr& msg, const int flags, const int timeout)
|
||||
{
|
||||
int nbytes = -1;
|
||||
int elapsed = 0;
|
||||
|
||||
zmq_msg_t* msgPtr = static_cast<FairMQMessageSHM*>(msg.get())->GetMessage();
|
||||
while (true)
|
||||
{
|
||||
nbytes = zmq_msg_recv(msgPtr, fSocket, flags);
|
||||
int nbytes = zmq_msg_recv(msgPtr, fSocket, flags);
|
||||
if (nbytes == 0)
|
||||
{
|
||||
++fMessagesRx;
|
||||
@@ -249,7 +247,6 @@ int FairMQSocketSHM::ReceiveImpl(FairMQMessagePtr& msg, const int flags, const i
|
||||
int64_t FairMQSocketSHM::SendImpl(vector<FairMQMessagePtr>& msgVec, const int flags, const int timeout)
|
||||
{
|
||||
const unsigned int vecSize = msgVec.size();
|
||||
int64_t totalSize = 0;
|
||||
int elapsed = 0;
|
||||
|
||||
if (vecSize == 1) {
|
||||
@@ -263,7 +260,7 @@ int64_t FairMQSocketSHM::SendImpl(vector<FairMQMessagePtr>& msgVec, const int fl
|
||||
// prepare the message with shm metas
|
||||
MetaHeader* metas = static_cast<MetaHeader*>(zmq_msg_data(&zmqMsg));
|
||||
|
||||
for (auto &msg : msgVec)
|
||||
for (auto& msg : msgVec)
|
||||
{
|
||||
zmq_msg_t* metaMsg = static_cast<FairMQMessageSHM*>(msg.get())->GetMessage();
|
||||
memcpy(metas++, zmq_msg_data(metaMsg), sizeof(MetaHeader));
|
||||
@@ -271,9 +268,8 @@ int64_t FairMQSocketSHM::SendImpl(vector<FairMQMessagePtr>& msgVec, const int fl
|
||||
|
||||
while (!fInterrupted)
|
||||
{
|
||||
int nbytes = -1;
|
||||
nbytes = zmq_msg_send(&zmqMsg, fSocket, flags);
|
||||
|
||||
int64_t totalSize = 0;
|
||||
int nbytes = zmq_msg_send(&zmqMsg, fSocket, flags);
|
||||
if (nbytes == 0)
|
||||
{
|
||||
zmq_msg_close(&zmqMsg);
|
||||
@@ -283,7 +279,7 @@ int64_t FairMQSocketSHM::SendImpl(vector<FairMQMessagePtr>& msgVec, const int fl
|
||||
{
|
||||
assert(nbytes == (vecSize * sizeof(MetaHeader))); // all or nothing
|
||||
|
||||
for (auto &msg : msgVec)
|
||||
for (auto& msg : msgVec)
|
||||
{
|
||||
FairMQMessageSHM* shmMsg = static_cast<FairMQMessageSHM*>(msg.get());
|
||||
shmMsg->fQueued = true;
|
||||
@@ -338,7 +334,6 @@ int64_t FairMQSocketSHM::SendImpl(vector<FairMQMessagePtr>& msgVec, const int fl
|
||||
|
||||
int64_t FairMQSocketSHM::ReceiveImpl(vector<FairMQMessagePtr>& msgVec, const int flags, const int timeout)
|
||||
{
|
||||
int64_t totalSize = 0;
|
||||
int elapsed = 0;
|
||||
|
||||
zmq_msg_t zmqMsg;
|
||||
@@ -346,6 +341,7 @@ int64_t FairMQSocketSHM::ReceiveImpl(vector<FairMQMessagePtr>& msgVec, const int
|
||||
|
||||
while (!fInterrupted)
|
||||
{
|
||||
int64_t totalSize = 0;
|
||||
int nbytes = zmq_msg_recv(&zmqMsg, fSocket, flags);
|
||||
if (nbytes == 0)
|
||||
{
|
||||
|
@@ -145,8 +145,6 @@ FairMQTransportFactorySHM::FairMQTransportFactorySHM(const string& id, const Fai
|
||||
|
||||
void FairMQTransportFactorySHM::StartMonitor()
|
||||
{
|
||||
int numTries = 0;
|
||||
|
||||
auto env = boost::this_process::environment();
|
||||
|
||||
vector<bfs::path> ownPath = boost::this_process::path();
|
||||
@@ -161,7 +159,7 @@ void FairMQTransportFactorySHM::StartMonitor()
|
||||
if (!p.empty())
|
||||
{
|
||||
boost::process::spawn(p, "-x", "-s", fSessionName, "-d", "-t", "2000", env);
|
||||
|
||||
int numTries = 0;
|
||||
do
|
||||
{
|
||||
MonitorStatus* monitorStatus = fManager->ManagementSegment().find<MonitorStatus>(bipc::unique_instance).first;
|
||||
|
@@ -245,11 +245,11 @@ void Monitor::Interactive()
|
||||
|
||||
void Monitor::CheckSegment()
|
||||
{
|
||||
static uint64_t counter = 0;
|
||||
char c = '#';
|
||||
|
||||
if (fInteractive)
|
||||
{
|
||||
static uint64_t counter = 0;
|
||||
int mod = counter++ % 5;
|
||||
switch (mod)
|
||||
{
|
||||
|
@@ -71,7 +71,7 @@ int main(int argc, char** argv)
|
||||
bool cleanup = false;
|
||||
bool selfDestruct = false;
|
||||
bool interactive = false;
|
||||
unsigned int timeoutInMS;
|
||||
unsigned int timeoutInMS = 5000;
|
||||
bool runAsDaemon = false;
|
||||
bool cleanOnExit = false;
|
||||
|
||||
|
Reference in New Issue
Block a user