Skip to content

Commit

Permalink
http: remove reference to onParserExecute
Browse files Browse the repository at this point in the history
Parsers hold a reference to the socket associated with the request
through onParserExecute. This must be removed when the parser is
freed so that the socket can be garbage collected when destroyed.

Regression introduced in commit 59b91f1 ("http_parser: consume
StreamBase instance").

PR-URL: #4773
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
  • Loading branch information
Tom Atkinson authored and rvagg committed Jan 25, 2016
1 parent 2119c76 commit 9b03af2
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/_http_common.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const kOnHeaders = HTTPParser.kOnHeaders | 0;
const kOnHeadersComplete = HTTPParser.kOnHeadersComplete | 0;
const kOnBody = HTTPParser.kOnBody | 0;
const kOnMessageComplete = HTTPParser.kOnMessageComplete | 0;
const kOnExecute = HTTPParser.kOnExecute | 0;

// Only called in the slow case where slow means
// that the request headers were either fragmented
Expand Down Expand Up @@ -151,6 +152,7 @@ var parsers = new FreeList('parsers', 1000, function() {
parser[kOnHeadersComplete] = parserOnHeadersComplete;
parser[kOnBody] = parserOnBody;
parser[kOnMessageComplete] = parserOnMessageComplete;
parser[kOnExecute] = null;

return parser;
});
Expand All @@ -175,6 +177,7 @@ function freeParser(parser, req, socket) {
parser.socket.parser = null;
parser.socket = null;
parser.incoming = null;
parser[kOnExecute] = null;
if (parsers.free(parser) === false)
parser.close();
parser = null;
Expand Down

0 comments on commit 9b03af2

Please sign in to comment.