JustinTulloss/zeromq.node — pull request #169 by jeremybarnes (2013-01-03 21:45:00+00:00)
Title: fixed hanging testcases on fast Linux machines

This patch fixes the hanging test.socket.pub-sub*.js testcases.

They hang on my fast Linux box. It's due to a race between connect() (which executes asynchronously and gives no way to know when it's completed in zmq 2.x) and the publishing of the messages:

No race:

connect() [ in progress ]
connect() [ finished ]
send() [ works as something is listening]

Race:

connect() [ in progress ]
send() [ dropped as nothing is listening ]
connect() [ finished ]

The fix adds a 100ms delay between the connect() and the send() to make sure that the connect is able to complete and so that the send()ed message isn't dropped. Note that the race occurs even with a inproc:// connection.