-
-
Notifications
You must be signed in to change notification settings - Fork 34.4k
Closed
Labels
fsIssues and PRs related to the fs subsystem / file system.Issues and PRs related to the fs subsystem / file system.streamIssues and PRs related to the stream subsystem.Issues and PRs related to the stream subsystem.
Description
From nodejs/node-v0.x-archive#6041 (comment):
var http = require('http');
var fs = require('fs');
var filename = process.argv[0];
var filesize = fs.statSync(filename).size;
http.createServer(function(req, res){
var file = fs.createReadStream(filename);
res.writeHead(200, { 'Content-Length': '' + filesize });
// uncommenting the line below fixes the fd leak
//res.on('close', file.destroy.bind(file));
file.pipe(res);
}).listen(8080);Hit with ab but ^C before it completes and check the open files afterwards:
$ ab -c 1000 -n 1000 http://127.0.0.1:8080/
^C
$ lsof -p $(pgrep iojs) | wc -l
928
$ ab -c 1000 -n 1000 http://127.0.0.1:8080/
^C
$ lsof -p $(pgrep iojs) | wc -l
1928
$ ab -c 1000 -n 1000 http://127.0.0.1:8080/
^C
$ lsof -p $(pgrep iojs) | wc -l
2791
# etc.
I think we should assign some prio to this even if it's an old bug because it's a great way to DoS a server.
/cc @nodejs/streams
binki
Metadata
Metadata
Assignees
Labels
fsIssues and PRs related to the fs subsystem / file system.Issues and PRs related to the fs subsystem / file system.streamIssues and PRs related to the stream subsystem.Issues and PRs related to the stream subsystem.