mirror of
https://github.com/nodejs/node.git
synced 2026-11-27 17:52:27 -05:00
test: fix flaky cluster-net-send
Before this commit, it was possible on Windows for the server's 'connection' handler to be called *after* the client socket's 'connect' handler. This caused the 'message' event to be missed and the test would never end (timing out in CI). This problem was more easily reproducible on a low resource (slow CPU) Windows (2012r2) installation. This commit waits until both handlers have been called before sending the handle to the master process. Fixes: https://github.com/nodejs/node/issues/3957 PR-URL: https://github.com/nodejs/node/pull/4444 Reviewed-By: Rich Trott <rtrott@gmail.com>
This commit is contained in:
1 parent
03c4bc704f
commit
715afc9bbd
2 files changed
+9
-4
No files matched your search
@@ -7,7 +7,6 @@ prefix parallel
|
||||
[true] # This section applies to all platforms
|
||||
|
||||
[$system==win32]
|
||||
test-cluster-net-send : PASS,FLAKY
|
||||
test-cluster-shared-leak : PASS,FLAKY
|
||||
test-debug-no-context : PASS,FLAKY
|
||||
test-tls-ticket-cluster : PASS,FLAKY
|
||||
|
||||
@@ -31,16 +31,22 @@ if (process.argv[2] !== 'child') {
|
||||
} else {
|
||||
console.error('[%d] worker', process.pid);
|
||||
|
||||
var socket;
|
||||
var cbcalls = 0;
|
||||
function socketConnected() {
|
||||
if (++cbcalls === 2)
|
||||
process.send('handle', socket);
|
||||
}
|
||||
|
||||
var server = net.createServer(function(c) {
|
||||
process.once('message', function(msg) {
|
||||
assert.equal(msg, 'got');
|
||||
c.end('hello');
|
||||
});
|
||||
socketConnected();
|
||||
});
|
||||
server.listen(common.PORT, function() {
|
||||
var socket = net.connect(common.PORT, '127.0.0.1', function() {
|
||||
process.send('handle', socket);
|
||||
});
|
||||
socket = net.connect(common.PORT, '127.0.0.1', socketConnected);
|
||||
});
|
||||
|
||||
process.on('disconnect', function() {
|
||||
|
||||
Reference in new issue
Block a user