diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2011-11-08 17:03:29 -0800 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2011-11-08 17:03:29 -0800 |
commit | da9bf0ee809ea467358c5174b27b635ba2ae47ba (patch) | |
tree | 855088bcd6229620e91b8c0b38d3b4323411eced /lib | |
parent | 3ae644d48cad70bcde3b5c367aa9ac64c2a24ae3 (diff) | |
download | node-new-da9bf0ee809ea467358c5174b27b635ba2ae47ba.tar.gz |
Fixes #2047. Fill workers array immediately after fork
Diffstat (limited to 'lib')
-rw-r--r-- | lib/cluster.js | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/cluster.js b/lib/cluster.js index 01547d6089..807ce8044a 100644 --- a/lib/cluster.js +++ b/lib/cluster.js @@ -102,7 +102,7 @@ function handleWorkerMessage(worker, message) { switch (message.cmd) { case 'online': console.log("Worker " + worker.pid + " online"); - workers[message._workerId] = worker; + worker.online = true; break; case 'queryServer': @@ -158,6 +158,8 @@ cluster.fork = function() { var worker = fork(workerFilename, workerArgs, { env: envCopy }); + workers[id] = worker; + worker.on('message', function(message) { handleWorkerMessage(worker, message); }); @@ -169,7 +171,7 @@ cluster.fork = function() { }); return worker; -} +}; // Internal function. Called from src/node.js when worker process starts. |