ZMQ 4.1.4, Recv returns -1 with EINTR error
Kadle11 opened this issue · 4 comments
I am relatively new to ZMQ and have read the Guide to obtain a basic understanding.
The program has two threads are all the sockets being used by a thread are initialized in the same thread.
I am facing the following error,
while(more)
{
/* Get The Pair */
clock_gettime(CLOCK_REALTIME, &S2);
nByteS = zmq_recv(reciever, data, sizeof(char), 0);
assert(nByteS != -1);
/* Multilply the Pair */
clock_gettime(CLOCK_REALTIME, &S3);
theApp->run(PairList[count].M2, PairList[count].M1, PairList[count].P, 16, &Sum4, &Sum4, &Sum3, &Sum4);
clock_gettime(CLOCK_REALTIME, &E3);
/* Check if there is more data */
more = (long int)(*data)&more_mask;
loop = (long int)(*data)&loop_mask;
/* Send the Product along with the indication of whether there is more data */
//printf("Sending Product Matrix... %ld\n", more);
if(loop)
{
nByteR = zmq_send(sendResult, msg, 2, 0);
assert(nByteR!=-1);
}
clock_gettime(CLOCK_REALTIME, &E2);
Sum1+=Exec_Time(S2, S3);
Sum2+=Exec_Time(S3, E3);
count = (count+1)%noOfPairs;
}
The sockets being used are initialized in the same thread.
The zmq_recv function is returning -1 with errno set to EINTR
The guide shows a program where the program continues to execute on receiving this error code.
Am I supposed to do the same?
PairList
is a shared variable between the threads. Could this be the cause of the Error?
EINTR can happen on receiving a signal. You need to try again if that happens.
Do I send and receive the same message or just call zmq_recv again?
If the send succeeded, then it succeeded. You need to handle the receive logic. Bear in mind that usually an interrupted receive means there was a ctrl-c or something like that requesting termination, so you need to handle that accordingly to your application's logic.
Okay, Thanks alot!