Skip to content

Commit 605329d

Browse files
committed
asyncwrap: fix constructor condition for early ret
AsyncWrap should always properly propagate asynchronous calls to any child that is created. Regardless whether kCallInitHook is currently active. The previous logic would always return early if kCallInitHook wasn't set. PR-URL: nodejs/node-v0.x-archive#9146 Reviewed-by: Julien Gilli <julien.gilli@joyent.com>
1 parent a5dbcc9 commit 605329d

File tree

4 files changed

+18
-1
lines changed

4 files changed

+18
-1
lines changed

src/async-wrap-inl.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ inline AsyncWrap::AsyncWrap(Environment* env,
4343
has_async_queue_(false),
4444
provider_type_(provider) {
4545
// Check user controlled flag to see if the init callback should run.
46-
if (!env->call_async_init_hook())
46+
if (!env->using_asyncwrap())
47+
return;
48+
if (!env->call_async_init_hook() && parent == NULL)
4749
return;
4850

4951
// TODO(trevnorris): Until it's verified all passed object's are not weak,

src/async-wrap.cc

+2
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ static void SetupHooks(const FunctionCallbackInfo<Value>& args) {
6969
env->set_async_hooks_init_function(args[1].As<Function>());
7070
env->set_async_hooks_pre_function(args[2].As<Function>());
7171
env->set_async_hooks_post_function(args[3].As<Function>());
72+
73+
env->set_using_asyncwrap(true);
7274
}
7375

7476

src/env-inl.h

+9
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ inline Environment::Environment(v8::Local<v8::Context> context,
210210
isolate_data_(IsolateData::GetOrCreate(context->GetIsolate(), loop)),
211211
using_smalloc_alloc_cb_(false),
212212
using_domains_(false),
213+
using_asyncwrap_(false),
213214
printed_error_(false),
214215
debugger_agent_(this),
215216
context_(context->GetIsolate(), context) {
@@ -343,6 +344,14 @@ inline void Environment::set_using_domains(bool value) {
343344
using_domains_ = value;
344345
}
345346

347+
inline bool Environment::using_asyncwrap() const {
348+
return using_asyncwrap_;
349+
}
350+
351+
inline void Environment::set_using_asyncwrap(bool value) {
352+
using_asyncwrap_ = value;
353+
}
354+
346355
inline bool Environment::printed_error() const {
347356
return printed_error_;
348357
}

src/env.h

+4
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,9 @@ class Environment {
430430
inline bool using_domains() const;
431431
inline void set_using_domains(bool value);
432432

433+
inline bool using_asyncwrap() const;
434+
inline void set_using_asyncwrap(bool value);
435+
433436
inline bool printed_error() const;
434437
inline void set_printed_error(bool value);
435438

@@ -499,6 +502,7 @@ class Environment {
499502
ares_task_list cares_task_list_;
500503
bool using_smalloc_alloc_cb_;
501504
bool using_domains_;
505+
bool using_asyncwrap_;
502506
QUEUE gc_tracker_queue_;
503507
bool printed_error_;
504508
debugger::Agent debugger_agent_;

0 commit comments

Comments
 (0)