[zeromq-dev] assert in epoll.cpp line 71
Zoufal Andreas
Andreas.Zoufal at ait.ac.at
Wed Jan 26 17:32:35 CET 2011
Hello,
Maybe I do something wrong but I cannot find the right strategy to avoid this problem. I'm testing how the 0MQ lib acts on heavy traffic between multiple PUB threads and SUB threads. Increasing the number of threads and cross-connections between PUBs and SUBs I get often one of 2 effects:
1) System hangup
2) internal assert from the library
The internal assert looks like this partial output:
Server 16: started
Client 17: started
Server 17: started
Client 16: started
Server 19: started
Server 18: started
Bad file descriptor
rc != -1 (epoll.cpp:71)
Do you know this behavior? See the attached minimal code.
Kind regards,
Andi
System: PC, Ubuntu 10.04 32 Bit, 0MQ 2.0.10
--- CODE ATTACHEMENT ---
#define _BSD_SOURCE
#include <stdio.h>
#include <string.h>
#include <pthread.h>
#include <unistd.h>
#include <zmq.h>
#define THREADS 20
void *hContext = NULL;
//const char *pszFormat = "inproc://inproc%d";
const char *pszFormat = "ipc://pub%d.ipc";
//const char *pszFormat = "tcp://100%d.ipc";
static void *threadServer (void *pArg) {
int id = (int) pArg;
void *hSock;
char str[40];
printf("Server %d: started\n", id);
hSock = zmq_socket(hContext, ZMQ_PUB);
sprintf(str, pszFormat, id);
zmq_bind(hSock, str);
sleep(3); // do something
zmq_close(hSock);
printf("Server %d: finished\n", id);
return pArg;
}
static void *threadClient (void *pArg) {
int id = (int) pArg;
void *hSock;
char str[40];
int i;
printf("Client %d: started\n", id);
hSock = zmq_socket(hContext, ZMQ_SUB);
zmq_setsockopt(hSock, ZMQ_SUBSCRIBE, "", 0);
for (i = 0; i < THREADS; i += 1) {
sprintf(str, pszFormat, i);
zmq_connect(hSock, str);
}
sleep(3); // do something
zmq_close(hSock);
printf("Client: finished\n");
return pArg;
}
int main(void) {
pthread_t clients[THREADS];
pthread_t servers[THREADS];
int i;
hContext = zmq_init(1);
for(i = 0; i < THREADS; i += 1) {
pthread_create(&clients[i], NULL, threadClient, (void *) i);
}
for(i = 0; i < THREADS; i += 1) {
pthread_create(&servers[i], NULL, threadServer, (void *) i);
}
for(i = 0; i < THREADS; i += 1) {
pthread_join(servers[i], NULL);
}
for(i = 0; i < THREADS; i += 1) {
pthread_join(clients[i], NULL);
}
zmq_term(hContext);
return 0;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20110126/7cb31b28/attachment.htm>
More information about the zeromq-dev
mailing list