| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -21,11 +21,13 @@ | |||
| 21 | 21 | ||
| 22 | 22 | 'use strict'; | |
| 23 | 23 | const common = require('../common'); | |
| 24 | + const Countdown = require('../common/countdown'); | ||
| 24 | 25 | ||
| 25 | 26 | const http = require('http'); | |
| 26 | 27 | const net = require('net'); | |
| 27 | 28 | ||
| 28 | 29 | const seeds = [ 3, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4 ]; | |
| 30 | + const countdown = new Countdown(seeds.length, () => server.close()); | ||
| 29 | 31 | ||
| 30 | 32 | // Set up some timing issues where sockets can be destroyed | |
| 31 | 33 | // via either the req or res. | |
@@ -72,11 +74,8 @@ function generator(seeds) { | |||
| 72 | 74 | ||
| 73 | 75 | server.listen(0, common.mustCall(function() { | |
| 74 | 76 | const client = net.connect({ port: this.address().port }); | |
| 75 | - let done = 0; | ||
| 76 | 77 | server.on('requestDone', function() { | |
| 77 | - if (++done === seeds.length) { | ||
| 78 | - server.close(); | ||
| 79 | - } | ||
| 78 | + countdown.dec(); | ||
| 80 | 79 | }); | |
| 81 | 80 | ||
| 82 | 81 | // immediately write the pipelined requests. | |
| Back | FazBrowse Home | New Git URL |
0 commit comments