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>
This commit is contained in:
Daniel BeckertandMatheus Marchini authored and Matheus Marchini committed 2019-04-22 11:51:46 -07:00
1 parent 5aaf666b3b
commit ece507394a
13 files changed
+102 -32

No files matched your search

+6 -2
View File
@@ -602,11 +602,15 @@ void AsyncWrap::EmitDestroy(Environment* env, double async_id) {
env->destroy_async_id_list()->push_back(async_id);
}
void AsyncWrap::AsyncReset(double execution_async_id, bool silent) {
AsyncReset(object(), execution_async_id, silent);
}
// Generalized call for both the constructor and for handles that are pooled
// and reused over their lifetime. This way a new uid can be assigned when
// the resource is pulled out of the pool and put back into use.
void AsyncWrap::AsyncReset(double execution_async_id, bool silent) {
void AsyncWrap::AsyncReset(Local<Object> resource, double execution_async_id,
bool silent) {
if (async_id_ != -1) {
// This instance was in use before, we have already emitted an init with
// its previous async_id and need to emit a matching destroy for that
@@ -643,7 +647,7 @@ void AsyncWrap::AsyncReset(double execution_async_id, bool silent) {
if (silent) return;
EmitAsyncInit(env(), object(),
EmitAsyncInit(env(), resource,
env()->async_hooks()->provider_string(provider_type()),
async_id_, trigger_async_id_);
}