Skip to content

Commit

Permalink
test: use Countdown in http test
Browse files Browse the repository at this point in the history
PR-URL: #17506
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Jon Moss <me@jonathanmoss.me>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
  • Loading branch information
idandagan1 authored and gibfahn committed Dec 20, 2017
1 parent 67c526f commit 23edd08
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions test/parallel/test-http-incoming-pipelined-socket-destroy.js
@@ -1,10 +1,12 @@
'use strict'; 'use strict';
const common = require('../common'); const common = require('../common');
const Countdown = require('../common/countdown');


const http = require('http'); const http = require('http');
const net = require('net'); const net = require('net');


const seeds = [ 3, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4 ]; const seeds = [ 3, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4 ];
const countdown = new Countdown(seeds.length, () => server.close());


// Set up some timing issues where sockets can be destroyed // Set up some timing issues where sockets can be destroyed
// via either the req or res. // via either the req or res.
Expand Down Expand Up @@ -51,11 +53,8 @@ function generator(seeds) {


server.listen(0, common.mustCall(function() { server.listen(0, common.mustCall(function() {
const client = net.connect({ port: this.address().port }); const client = net.connect({ port: this.address().port });
let done = 0;
server.on('requestDone', function() { server.on('requestDone', function() {
if (++done === seeds.length) { countdown.dec();
server.close();
}
}); });


// immediately write the pipelined requests. // immediately write the pipelined requests.
Expand Down

0 comments on commit 23edd08

Please sign in to comment.