| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -21,6 +21,7 @@ | |||
| 21 | 21 | ||
| 22 | 22 | 'use strict'; | |
| 23 | 23 | const common = require('../common'); | |
| 24 | + const Countdown = require('../common/countdown'); | ||
| 24 | 25 | const assert = require('assert'); | |
| 25 | 26 | const http = require('http'); | |
| 26 | 27 | common.crashOnUnhandledRejection(); | |
@@ -33,14 +34,17 @@ const server = http.Server(common.mustCall(function(req, res) { | |||
| 33 | 34 | }, (N * M))); // N * M = good requests (the errors will not be counted) | |
| 34 | 35 | ||
| 35 | 36 | function makeRequests(outCount, inCount, shouldFail) { | |
| 36 | - let responseCount = outCount * inCount; | ||
| 37 | + const countdown = new Countdown( | ||
| 38 | + outCount * inCount, | ||
| 39 | + common.mustCall(() => server.close()) | ||
| 40 | + ); | ||
| 37 | 41 | let onRequest = common.mustNotCall(); // Temporary | |
| 38 | 42 | const p = new Promise((resolve) => { | |
| 39 | 43 | onRequest = common.mustCall((res) => { | |
| 40 | - if (--responseCount === 0) { | ||
| 41 | - server.close(); | ||
| 44 | + if (countdown.dec() === 0) { | ||
| 42 | 45 | resolve(); | |
| 43 | 46 | } | |
| 47 | + | ||
| 44 | 48 | if (!shouldFail) | |
| 45 | 49 | res.resume(); | |
| 46 | 50 | }, outCount * inCount); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments