mirror of
https://github.com/nodejs/node.git
synced 2026-11-30 11:55:44 -05:00
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>
This commit is contained in:
1 parent
980852165f
commit
761af37d0e
1 file changed
+5
-3
@@ -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 ++;
|
||||
|
||||
Reference in new issue
Block a user