Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2012-07-29 03:59:26 +0400
committerBen Noordhuis <info@bnoordhuis.nl>2012-07-29 04:07:16 +0400
commitaa0650f4444c438d9538135a3707de3f2f313081 (patch)
tree89e3b58d644ca7f7f58a8fae1f5c6cdaef21e51f /lib
parent879d329a5a8d82d9c30e1439ff36accbf5d8a1e7 (diff)
cluster: fix libuv assert in net.listen()
Problem: calling `server.listen()` (no port) on a net.Server triggered the following libuv assertion: node: ../deps/uv/src/unix/stream.c:406: uv__write: Assertion `fd_to_send >= 0' failed. Cause: uv_tcp_t handles are lazily initialized. Omitting the port made the handle get initialized even more lazily. Too lazily - it wasn't initialized when the handle was sent over to the child process. Solution: implicitly bind to a random port in listen() when the port number is omitted, it forces the handle to initialize. This is not a change in behavior, listen() has always been identical to listen(0). Fixes #3325.
Diffstat (limited to 'lib')
-rw-r--r--lib/net.js5
1 files changed, 2 insertions, 3 deletions
diff --git a/lib/net.js b/lib/net.js
index 170c06e57a6..b6cbe4f5410 100644
--- a/lib/net.js
+++ b/lib/net.js
@@ -967,9 +967,8 @@ Server.prototype.listen = function() {
var TCP = process.binding('tcp_wrap').TCP;
if (arguments.length == 0 || typeof arguments[0] == 'function') {
- // Don't bind(). OS will assign a port with INADDR_ANY.
- // The port can be found with server.address()
- listen(self, null, null, backlog);
+ // Bind to a random port.
+ listen(self, '0.0.0.0', 0, null, backlog);
} else if (arguments[0] && typeof arguments[0] === 'object') {
var h = arguments[0];