Simplify the handling of send/receive timeouts

This commit is contained in:
Alexey Rybalchenko
2015-11-19 15:30:37 +01:00
committed by Florian Uhlig
parent 0894900f52
commit afda64a83d
3 changed files with 53 additions and 73 deletions

View File

@@ -583,60 +583,62 @@ int FairMQChannel::Receive(FairMQMessage* msg, const int flags) const
}
}
bool FairMQChannel::SetSendTimeout(const int timeout)
void FairMQChannel::SetSendTimeout(const int timeout)
{
if (fSocket)
{
if (fSocket->SetSendTimeout(timeout, fAddress, fMethod))
{
// if (fSocket)
// {
// if (fSocket->SetSendTimeout(timeout, fAddress, fMethod))
// {
fSndTimeoutInMs = timeout;
return true;
}
}
// return true;
// }
// }
LOG(ERROR) << "SetSendTimeout() failed - socket is not initialized!";
return false;
// LOG(ERROR) << "SetSendTimeout() failed - socket is not initialized!";
// return false;
}
int FairMQChannel::GetSendTimeout() const
{
if (fSocket)
{
return fSocket->GetSendTimeout();
}
else
{
LOG(ERROR) << "GetSendTimeout() failed - socket is not initialized!";
return -1;
}
return fSndTimeoutInMs;
// if (fSocket)
// {
// return fSocket->GetSendTimeout();
// }
// else
// {
// LOG(ERROR) << "GetSendTimeout() failed - socket is not initialized!";
// return -1;
// }
}
bool FairMQChannel::SetReceiveTimeout(const int timeout)
void FairMQChannel::SetReceiveTimeout(const int timeout)
{
if (fSocket)
{
if (fSocket->SetReceiveTimeout(timeout, fAddress, fMethod))
{
// if (fSocket)
// {
// if (fSocket->SetReceiveTimeout(timeout, fAddress, fMethod))
// {
fRcvTimeoutInMs = timeout;
return true;
}
}
// return true;
// }
// }
LOG(ERROR) << "SetReceiveTimeout() failed - socket is not initialized!";
return false;
// LOG(ERROR) << "SetReceiveTimeout() failed - socket is not initialized!";
// return false;
}
int FairMQChannel::GetReceiveTimeout() const
{
if (fSocket)
{
return fSocket->GetReceiveTimeout();
}
else
{
LOG(ERROR) << "GetReceiveTimeout() failed - socket is not initialized!";
return -1;
}
return fRcvTimeoutInMs;
// if (fSocket)
// {
// return fSocket->GetReceiveTimeout();
// }
// else
// {
// LOG(ERROR) << "GetReceiveTimeout() failed - socket is not initialized!";
// return -1;
// }
}
bool FairMQChannel::ExpectsAnotherPart() const