mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-16 18:11:49 +00:00
- Proper process termination:
if interrupted with CTRL+C blocking socket calls will return with -1. Each device should call FairMQDevice::Shutdown() before ending the running state to close open sockets, otherwise the interrupt call itself will block. - FIX: Update number of received messages for FairMQFileSink. - Add ability to poll on outputs for FairMQPoller.
This commit is contained in:
committed by
Mohammad Al-Turany
parent
8cd120aef4
commit
0a610926a1
@@ -13,6 +13,7 @@
|
||||
*/
|
||||
|
||||
#include <cstring>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <nanomsg/nn.h>
|
||||
|
||||
|
@@ -41,6 +41,14 @@ bool FairMQPollerNN::CheckInput(int index)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool FairMQPollerNN::CheckOutput(int index)
|
||||
{
|
||||
if (items[index].revents & NN_POLLOUT)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
FairMQPollerNN::~FairMQPollerNN()
|
||||
{
|
||||
if (items != NULL)
|
||||
|
@@ -29,6 +29,7 @@ class FairMQPollerNN : public FairMQPoller
|
||||
|
||||
virtual void Poll(int timeout);
|
||||
virtual bool CheckInput(int index);
|
||||
virtual bool CheckOutput(int index);
|
||||
|
||||
virtual ~FairMQPollerNN();
|
||||
|
||||
|
@@ -69,7 +69,7 @@ void FairMQSocketNN::Connect(const string& address)
|
||||
}
|
||||
}
|
||||
|
||||
size_t FairMQSocketNN::Send(FairMQMessage* msg, const string& flag)
|
||||
int FairMQSocketNN::Send(FairMQMessage* msg, const string& flag)
|
||||
{
|
||||
void* ptr = msg->GetMessage();
|
||||
int rc = nn_send(fSocket, &ptr, NN_MSG, 0);
|
||||
@@ -87,7 +87,7 @@ size_t FairMQSocketNN::Send(FairMQMessage* msg, const string& flag)
|
||||
return rc;
|
||||
}
|
||||
|
||||
size_t FairMQSocketNN::Receive(FairMQMessage* msg, const string& flag)
|
||||
int FairMQSocketNN::Receive(FairMQMessage* msg, const string& flag)
|
||||
{
|
||||
void* ptr = NULL;
|
||||
int rc = nn_recv(fSocket, &ptr, NN_MSG, 0);
|
||||
@@ -106,6 +106,16 @@ size_t FairMQSocketNN::Receive(FairMQMessage* msg, const string& flag)
|
||||
return rc;
|
||||
}
|
||||
|
||||
void FairMQSocketNN::Close()
|
||||
{
|
||||
nn_close(fSocket);
|
||||
}
|
||||
|
||||
void FairMQSocketNN::Terminate()
|
||||
{
|
||||
nn_term();
|
||||
}
|
||||
|
||||
void* FairMQSocketNN::GetSocket()
|
||||
{
|
||||
return NULL; // dummy method to comply with the interface. functionality not possible in zeromq.
|
||||
@@ -116,11 +126,6 @@ int FairMQSocketNN::GetSocket(int nothing)
|
||||
return fSocket;
|
||||
}
|
||||
|
||||
void FairMQSocketNN::Close()
|
||||
{
|
||||
nn_close(fSocket);
|
||||
}
|
||||
|
||||
void FairMQSocketNN::SetOption(const string& option, const void* value, size_t valueSize)
|
||||
{
|
||||
int rc = nn_setsockopt(fSocket, NN_SOL_SOCKET, GetConstant(option), value, valueSize);
|
||||
@@ -186,6 +191,8 @@ int FairMQSocketNN::GetConstant(const string& constant)
|
||||
LOG(ERROR) << "Multipart messages functionality currently not supported by nanomsg!";
|
||||
return -1;
|
||||
}
|
||||
if (constant == "linger")
|
||||
return NN_LINGER;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
@@ -31,12 +31,13 @@ class FairMQSocketNN : public FairMQSocket
|
||||
virtual void Bind(const string& address);
|
||||
virtual void Connect(const string& address);
|
||||
|
||||
virtual size_t Send(FairMQMessage* msg, const string& flag="");
|
||||
virtual size_t Receive(FairMQMessage* msg, const string& flag="");
|
||||
virtual int Send(FairMQMessage* msg, const string& flag="");
|
||||
virtual int Receive(FairMQMessage* msg, const string& flag="");
|
||||
|
||||
virtual void* GetSocket();
|
||||
virtual int GetSocket(int nothing);
|
||||
virtual void Close();
|
||||
virtual void Terminate();
|
||||
|
||||
virtual void SetOption(const string& option, const void* value, size_t valueSize);
|
||||
virtual void GetOption(const string& option, void* value, size_t* valueSize);
|
||||
|
Reference in New Issue
Block a user