Skip to content

Commit dc1ffd0

Browse files
orangemochatjfontaine
authored andcommitted
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.
1 parent 14d6df8 commit dc1ffd0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

test/simple/test-cluster-disconnect.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ if (cluster.isWorker) {
3535
}).listen(common.PORT + 1, '127.0.0.1');
3636

3737
} else if (cluster.isMaster) {
38+
var servers = 2;
3839

3940
// test a single TCP server
4041
var testConnection = function(port, cb) {
@@ -52,7 +53,6 @@ if (cluster.isWorker) {
5253

5354
// test both servers created in the cluster
5455
var testCluster = function(cb) {
55-
var servers = 2;
5656
var done = 0;
5757

5858
for (var i = 0, l = servers; i < l; i++) {
@@ -76,7 +76,7 @@ if (cluster.isWorker) {
7676
var worker = cluster.fork();
7777
worker.on('listening', function() {
7878
online += 1;
79-
if (online === workers) {
79+
if (online === workers * servers) {
8080
cb();
8181
}
8282
});

0 commit comments

Comments
 (0)