mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
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:
committed by
Timothy J Fontaine
parent
14d6df8702
commit
dc1ffd0da6
@@ -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();
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user