diff options
author | Daniel Beckert <drbeckert@gmail.com> | 2018-12-13 15:35:48 -0200 |
---|---|---|
committer | Matheus Marchini <mat@mmarchini.me> | 2019-04-22 11:51:46 -0700 |
commit | ece507394a563bd7e3555a840a3d6980ffbb01ac (patch) | |
tree | 1d06fac01c1ca69e88107f718d12859f78a55295 /lib/_http_server.js | |
parent | 5aaf666b3b82a66485bea6a6b59fbfc838192e2f (diff) | |
download | android-node-v8-ece507394a563bd7e3555a840a3d6980ffbb01ac.tar.gz android-node-v8-ece507394a563bd7e3555a840a3d6980ffbb01ac.tar.bz2 android-node-v8-ece507394a563bd7e3555a840a3d6980ffbb01ac.zip |
src: do not reuse async resource in http parsers
Change resource being used, previously HTTParser was being reused.
We are now using IncomingMessage and ClientRequest objects. The goal
here is to make the async resource unique for each async operatio
Refs: https://github.com/nodejs/node/pull/24330
Refs: https://github.com/nodejs/diagnostics/issues/248
Refs: https://github.com/nodejs/node/pull/21313
Co-authored-by: Matheus Marchini <mat@mmarchini.me>
PR-URL: https://github.com/nodejs/node/pull/25094
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Benedikt Meurer <benedikt.meurer@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Diffstat (limited to 'lib/_http_server.js')
-rw-r--r-- | lib/_http_server.js | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/_http_server.js b/lib/_http_server.js index ff29b9d2b6..9f62872e8e 100644 --- a/lib/_http_server.js +++ b/lib/_http_server.js @@ -126,6 +126,12 @@ const STATUS_CODES = { const kOnExecute = HTTPParser.kOnExecute | 0; +class HTTPServerAsyncResource { + constructor(type, socket) { + this.type = type; + this.socket = socket; + } +} function ServerResponse(req) { OutgoingMessage.call(this); @@ -349,9 +355,15 @@ function connectionListenerInternal(server, socket) { socket.setTimeout(server.timeout); socket.on('timeout', socketOnTimeout); - const isParserReused = parsers.hasItems(); const parser = parsers.alloc(); - parser.reinitialize(HTTPParser.REQUEST, isParserReused); + + // TODO(addaleax): This doesn't play well with the + // `async_hooks.currentResource()` proposal, see + // https://github.com/nodejs/node/pull/21313 + parser.initialize( + HTTPParser.REQUEST, + new HTTPServerAsyncResource('HTTPINCOMINGMESSAGE', socket) + ); parser.socket = socket; // We are starting to wait for our headers. |