cluster: avoid race enabling debugger in worker

Previously if a worker's state machine had already transitioned into the
'listening' state when it received the message enabling the debugger,
the worker would never enable its debugger.

Change the logic to allow the 'listening' as a valid state for enabling
the debugger.

Fixes: https://github.com/joyent/node/issues/6440
Original-PR-URL: https://github.com/joyent/node/pull/9037
Signed-off-by: Julien Gilli <julien.gilli@joyent.com>

Fixes: https://github.com/iojs/io.js/issues/340
PR-URL: https://github.com/iojs/io.js/pull/501
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Bert Belder <bertbelder@gmail.com>
Reviewed-By: Rod Vagg <rod@vagg.org>
This commit is contained in:
Timothy J Fontaine 2015-01-15 23:14:16 +00:00 committed by Ben Noordhuis
parent 6b91c78e20
commit 4dd22b946e

View File

@ -266,7 +266,7 @@ function masterInit() {
var key;
for (key in cluster.workers) {
var worker = cluster.workers[key];
if (worker.state === 'online') {
if (worker.state === 'online' || worker.state === 'listening') {
process._debugProcess(worker.process.pid);
} else {
worker.once('online', function() {