OK, so in your modified code, when you get NULL back from a recv call,
you have to exit the loop. This is how the blocking recv functions in
CZMQ signal an ETERM situation. zctx_interrupted will not be raised on
all threads, only the one that caught the Ctrl-C.

On Mon, Sep 2, 2013 at 5:19 AM, Chris Laws <clawsi...@gmail.com> wrote:
> After more investigation it appears that the problem I am seeing is
> associated with the thread code sitting blocked in recv until the main
> thread performs the context shutdown. When the thread begins shutting down
> it goes through the termination sequence of events, one of which is to set
> the linger option on sockets. I think it is this action which triggers the
> "Context was terminated" to be emitted to stdout.
>
> I modified the simple example to send a message, from main to the thread,
> upon detecting zctx_interrupted. This kicks the thread out of the blocking
> recv call sooner, allowing it to exit the while loop and begin shutting
> down. However, I found I still needed to insert a wait, allowing the thread
> to finish up, before shutting down the context to avoid triggering
> the"Context was terminated" error.
>
> The period of time I wait for the thread to shut down is a guess. Having a
> feature like thread join might resolve what appears to be a race condition
> here.
>
> Here is a modified version of the simple example that appears to work - it
> no longer raises the "Context was terminated" error to stdout on shutdown.
>
>
>
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev@lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>
_______________________________________________
zeromq-dev mailing list
zeromq-dev@lists.zeromq.org
http://lists.zeromq.org/mailman/listinfo/zeromq-dev

Reply via email to