forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
http: start connections checking interval on listen
Fixes: nodejs#48604.
- Loading branch information
1 parent
32eb492
commit 94b4764
Showing
3 changed files
with
61 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
test/parallel/test-http-server-connections-checking-leak.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
'use strict'; | ||
|
||
// Flags: --expose-gc | ||
|
||
const common = require('../common'); | ||
if (!common.hasCrypto) { common.skip('missing crypto'); } | ||
const onGC = require('../common/ongc'); | ||
const http = require('http'); | ||
const https = require('https'); | ||
|
||
// Check that creating a server without listening is not leaking resources. | ||
const max = 100; | ||
|
||
// HTTP | ||
{ | ||
const gcListener = common.mustCall(max); | ||
|
||
for (let i = 0; i <= max; i++) { | ||
if (i % 100 === 0) { | ||
global.gc(); | ||
} | ||
|
||
const server = http.createServer((req, res) => {}); | ||
onGC(server, { ongc: gcListener }); | ||
} | ||
|
||
global.gc(); | ||
} | ||
|
||
// HTTPS | ||
|
||
{ | ||
const gcListener = common.mustCall(max); | ||
|
||
for (let i = 0; i <= max; i++) { | ||
if (i % 100 === 0) { | ||
global.gc(); | ||
} | ||
|
||
const server = https.createServer((req, res) => {}); | ||
onGC(server, { ongc: gcListener }); | ||
} | ||
|
||
global.gc(); | ||
} |