cluster: propagate bind errors
authorBen Noordhuis <info@bnoordhuis.nl>
Thu, 9 Feb 2012 05:22:50 +0000 (06:22 +0100)
committerBen Noordhuis <info@bnoordhuis.nl>
Tue, 5 Mar 2013 14:23:55 +0000 (15:23 +0100)
commit532d9929c7e6eba8c35943f45dffc93926e34cb9
tree6720a7818170671f2272b4cea44b0a324e727706
parentecf9f606c9540f12ba539ddfe7b7827e34388fc7
cluster: propagate bind errors

This commit fixes a bug where the cluster module fails 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]