[zeromq-dev] weird block

Martin Sustrik sustrik at 250bpm.com
Tue Apr 26 16:29:28 CEST 2011


On 04/26/2011 04:22 PM, Andrew Hume wrote:
> god i hate distributed programming!

:)

> i have a program X receiving messages.
> it forwards those messages out to a set of worker processes for processing.
> X sends out the messages via a PUSH; the workers PULL the messages.
> i set the high water mark on the PUSH socket in X.
>
> so my controller program broadcasts out a 'quit' message to everyone
> and all of X's workers quit. now X also got a 'quit' message but now
> it never sees it because it is blocked in teh send of the messages it has.
> and that queue will never unblock because now there are no workers
> to eat from teh queue (which would allow the send to finish
> and thus get back to the poll where it could see the quit message).
>
> is there a recommended way around this?

I assume you are distributing the 'quit' command using a PUB/SUB 
topology, right?

If so, just poll on both the PUSH and SUB socket. The poll exits either 
if PUSH is available for writing or if there's a 'quit' message 
available in SUB socket.

Martin



More information about the zeromq-dev mailing list