Skip to content
This repository was archived by the owner on May 8, 2024. It is now read-only.

Commit dfeae0d

Browse files
committed
move async context into config ctx
1 parent 12ecbab commit dfeae0d

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

ngx_http_nodejs_module.cpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ typedef struct ngx_http_nodejs_loc_conf_s {
6666
v8::Global<v8::Context> context;
6767
v8::Global<v8::Function> function;
6868

69+
node::async_context asyncContext;
70+
6971
ngx_event_t timer;
7072
} ngx_http_nodejs_loc_conf_t;
7173

@@ -558,6 +560,8 @@ static void *start_nodejs (ngx_http_nodejs_loc_conf_t *ncf, ngx_http_request_t *
558560

559561
ncf->function = v8::Global<v8::Function>(isolate, func);
560562

563+
ncf->asyncContext = node::EmitAsyncInit(isolate, result->ToObject(setup->context()).ToLocalChecked(), "ClientRequest", -1);
564+
561565
return NGX_CONF_OK;
562566
}
563567

@@ -1259,7 +1263,6 @@ static void nodejs_release_context (void *data) {
12591263

12601264
ctx->request_data.SetWeak();
12611265
ctx->response_object.SetWeak();
1262-
node::EmitAsyncDestroy(ctx->isolate, ctx->asyncContext);
12631266
}
12641267

12651268
#define v8_persist_t v8::Persistent<v8::Object, v8::CopyablePersistentTraits<v8::Object>>
@@ -1320,7 +1323,7 @@ static v8::String::Utf8Value run_v8_script (
13201323
ctx->request_data = v8_persist_t(isolate, request_data);
13211324
ctx->response_object = v8_persist_t(isolate, response_object);
13221325

1323-
ctx->asyncContext = node::EmitAsyncInit(isolate, request_data, "ClientRequest", -1);
1326+
ctx->asyncContext = ncf->asyncContext;
13241327

13251328
v8::Local<v8::Value> argv[] = { request_data, response_object };
13261329

0 commit comments

Comments
 (0)