On Aug 28, 2010, at 1:14 PM, Pieter Hintjens wrote:

> On Sat, Aug 28, 2010 at 7:34 PM, Chuck Remes <[email protected]> wrote:
> 
>> I am wondering if I am misusing the framework. Briefly, the crash occurs 
>> when calling zmq_close from another thread on a socket that is blocked on 
>> send/recv. It sometimes asserts on object.cpp line 342, sometimes hangs, 
>> sometimes segfaults, etc.
>> 
>> I thought it would be safe to call zmq_close on sockets in other threads 
>> since calling zmq_term can safely do so. Am I wrong? If so, what is a safe 
>> way to signal a blocked socket so it can cleanly shut itself down (without 
>> calling zmq_term)?
> 
> Calling close on a socket that is not owned by that thread is not safe
> afaik.  The correct way to signal any socket is to send it a message.


How should sockets be cleaned up from languages that support 
destructors/finalizers? There will be situations where objects containing 
sockets will go out of scope and the garbage collector will reap them. At that 
time, a finalizer may be called to clean up the socket. That call will *always* 
happen from another thread.

If this can never be safe, then I'll remove my socket finalizers and just leave 
a finalizer for the context objects.

cr

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

Reply via email to