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.
This commit is contained in:
Alexis Campailla
2014-01-10 05:27:48 -08:00
committed by Timothy J Fontaine
parent 14d6df8702
commit dc1ffd0da6

View File

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