Browse Source

test: race condition in test-cluster-disconnect

The test was not waiting for all the worker-created sockets
to be listening before calling cluster.disconnect().
As a result, the channels with the workers could get closed
before all the socket handles had been passed to them, leading
to various errors.
v0.11.11-release
Alexis Campailla 11 years ago
committed by Timothy J Fontaine
parent
commit
dc1ffd0da6
  1. 4
      test/simple/test-cluster-disconnect.js

4
test/simple/test-cluster-disconnect.js

@ -35,6 +35,7 @@ if (cluster.isWorker) {
}).listen(common.PORT + 1, '127.0.0.1'); }).listen(common.PORT + 1, '127.0.0.1');
} else if (cluster.isMaster) { } else if (cluster.isMaster) {
var servers = 2;
// test a single TCP server // test a single TCP server
var testConnection = function(port, cb) { var testConnection = function(port, cb) {
@ -52,7 +53,6 @@ if (cluster.isWorker) {
// test both servers created in the cluster // test both servers created in the cluster
var testCluster = function(cb) { var testCluster = function(cb) {
var servers = 2;
var done = 0; var done = 0;
for (var i = 0, l = servers; i < l; i++) { for (var i = 0, l = servers; i < l; i++) {
@ -76,7 +76,7 @@ if (cluster.isWorker) {
var worker = cluster.fork(); var worker = cluster.fork();
worker.on('listening', function() { worker.on('listening', function() {
online += 1; online += 1;
if (online === workers) { if (online === workers * servers) {
cb(); cb();
} }
}); });

Loading…
Cancel
Save