On Jul 25, 2012, at 11:11 AM, Marc Rossi wrote:

> 
> Linux w/ ZMQ 2.2.0
> 
> I have a publish function that is called from a thread.  This publish
> function connects an inproc socket with a socket in another thread.
> Since inproc sockets error on a connect call if the other side isn't
> setup yet I have the publish functino return without publishing
> until the connection can be succesfully established.
> 
> This function publishes a high volume of data and sometimes when the
> other side of the socket takes a second or two to setup I run into
> the assertion
> 
>     Too many open files (signaler.cpp:330)
> 
> when it tries to create a socketpair.  Can't find where the socketpair
> gets cleaned up after deletion.
> 
> Am I missing something with my approach? Initially tried to reuse
> created socket instead of deleting/recreating every time but
> connect would never succeed.
> 

Unless there is some delay between attempts, you are probably trying to create 
and connect that socket hundreds or thousands of times per second until the 
other thread has completed its setup and called zmq_bind() on the inproc 
transport.

Socket deletion, like everything else in zeromq, is asynchronous. So, while you 
may have deleted the socket it does not mean that its resources have been 
reclaimed yet. In a tight enough loop you will run out of file descriptors 
because the "deleted" sockets are still holding on to unreleased file 
descriptors while they await their termination.

I suggest using a real signaling mechanism (like a condition variable) to 
indicate that your receiver thread has completed its setup. Only then should 
you try and create the publish socket and connect it.

cr


_______________________________________________
zeromq-dev mailing list
[email protected]
http://lists.zeromq.org/mailman/listinfo/zeromq-dev

Reply via email to