cluster: propagate bind errors
authorBen Noordhuis <info@bnoordhuis.nl>
Fri, 10 Feb 2012 19:26:56 +0000 (20:26 +0100)
committerBen Noordhuis <info@bnoordhuis.nl>
Thu, 16 Feb 2012 22:47:17 +0000 (23:47 +0100)
commit30e462e91937ced3847af3fe9c393ebd32294b68
tree5a5ab06977b87be25e8b4c550da13e51e13a7f25
parent83fd1c1de51e6b0171101a725c8d92081c2fadbd
cluster: propagate bind errors

This commit fixes a bug where the cluster module failed to propagate EADDRINUSE
errors.

When a worker starts a (net, http) server, it requests the listen socket from
its master who then creates and binds the socket.

Now, OS X and Windows don't always signal EADDRINUSE from bind() but instead
defer the error until a later syscall. libuv mimics this behaviour to provide
consistent behaviour across platforms but that means the worker could end up
with a socket that is not actually bound to the requested addresss.

That's why the worker now checks if the socket is bound, raising EADDRINUSE if
that's not the case.

Fixes #2721.
lib/net.js
test/simple/test-cluster-bind-twice-v1.js [moved from test/simple/test-cluster-bind-twice.js with 100% similarity]
test/simple/test-cluster-bind-twice-v2.js [new file with mode: 0644]