Browse Source

test: fix race condition in test-http-client-onerror

Occasionally test-http-client-onerror will fail with a refused connection.
This patch fixes the possibility that connections will be attempted before
server is listening.

PR-URL: https://github.com/nodejs/node/pull/4346
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
Reviewed-By: James M Snell <jasnell@gmail.com>
process-exit-stdio-flushing
Devin Nakamura 9 years ago
committed by James M Snell
parent
commit
2413a4e99d
  1. 8
      test/gc/test-http-client-onerror.js

8
test/gc/test-http-client-onerror.js

@ -22,7 +22,7 @@ console.log('We should do ' + todo + ' requests');
var http = require('http');
var server = http.createServer(serverHandler);
server.listen(PORT, getall);
server.listen(PORT, runTest);
function getall() {
if (count >= todo)
@ -51,8 +51,10 @@ function getall() {
setImmediate(getall);
}
for (var i = 0; i < 10; i++)
getall();
function runTest() {
for (var i = 0; i < 10; i++)
getall();
}
function afterGC() {
countGC ++;

Loading…
Cancel
Save