mirror of
https://github.com/nodejs/node.git
synced 2025-05-10 03:12:57 +00:00

Upcoming lint rule will require a blank line between consecutive functions. Add it in the places where we don't have it already. PR-URL: https://github.com/nodejs/node/pull/30696 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Denys Otrishko <shishugi@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
40 lines
878 B
JavaScript
40 lines
878 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const http = require('http');
|
|
|
|
const server = http.createServer((req, res) => res.end());
|
|
|
|
const tmpdir = require('../common/tmpdir');
|
|
tmpdir.refresh();
|
|
|
|
server.listen(common.PIPE, common.mustCall(() =>
|
|
asyncLoop(makeKeepAliveRequest, 10, common.mustCall(() =>
|
|
server.getConnections(common.mustCall((err, conns) => {
|
|
assert.ifError(err);
|
|
assert.strictEqual(conns, 1);
|
|
server.close();
|
|
}))
|
|
))
|
|
));
|
|
|
|
function asyncLoop(fn, times, cb) {
|
|
fn(function handler() {
|
|
if (--times) {
|
|
fn(handler);
|
|
} else {
|
|
cb();
|
|
}
|
|
});
|
|
}
|
|
|
|
function makeKeepAliveRequest(cb) {
|
|
http.get({
|
|
socketPath: common.PIPE,
|
|
headers: { connection: 'keep-alive' }
|
|
}, (res) => res.on('data', common.mustNotCall())
|
|
.on('error', assert.fail)
|
|
.on('end', cb)
|
|
);
|
|
}
|