Browse Source

src,http_parser: remove KickNextTick call

Now that HTTPParser uses MakeCallback it is unnecessary to manually
process the nextTickQueue.

The KickNextTick function is now no longer needed so code has moved back
to node::MakeCallback to simplify implementation.

Include minor cleanup moving Environment::tick_info() call below the
early return to save an operation.

PR-URL: https://github.com/nodejs/node/pull/5756
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Andreas Madsen <amwebdk@gmail.com>
process-exit-stdio-flushing
Trevor Norris 9 years ago
parent
commit
41f333e679
  1. 7
      src/async-wrap.cc
  2. 23
      src/env.cc
  3. 2
      src/env.h
  4. 18
      src/node.cc
  5. 4
      src/node_http_parser.cc

7
src/async-wrap.cc

@ -181,7 +181,6 @@ Local<Value> AsyncWrap::MakeCallback(const Local<Function> cb,
Local<Function> post_fn = env()->async_hooks_post_function();
Local<Value> uid = Integer::New(env()->isolate(), get_uid());
Local<Object> context = object();
Local<Object> process = env()->process_object();
Local<Object> domain;
bool has_domain = false;
@ -233,16 +232,18 @@ Local<Value> AsyncWrap::MakeCallback(const Local<Function> cb,
}
}
Environment::TickInfo* tick_info = env()->tick_info();
if (callback_scope.in_makecallback()) {
return ret;
}
Environment::TickInfo* tick_info = env()->tick_info();
if (tick_info->length() == 0) {
env()->isolate()->RunMicrotasks();
}
Local<Object> process = env()->process_object();
if (tick_info->length() == 0) {
tick_info->set_index(0);
return ret;

23
src/env.cc

@ -64,27 +64,4 @@ void Environment::PrintSyncTrace() const {
fflush(stderr);
}
bool Environment::KickNextTick(Environment::AsyncCallbackScope* scope) {
TickInfo* info = tick_info();
if (scope->in_makecallback()) {
return true;
}
if (info->length() == 0) {
isolate()->RunMicrotasks();
}
if (info->length() == 0) {
info->set_index(0);
return true;
}
Local<Value> ret =
tick_callback_function()->Call(process_object(), 0, nullptr);
return !ret.IsEmpty();
}
} // namespace node

2
src/env.h

@ -475,8 +475,6 @@ class Environment {
inline int64_t get_async_wrap_uid();
bool KickNextTick(AsyncCallbackScope* scope);
inline uint32_t* heap_statistics_buffer() const;
inline void set_heap_statistics_buffer(uint32_t* pointer);

18
src/node.cc

@ -1222,7 +1222,23 @@ Local<Value> MakeCallback(Environment* env,
}
}
if (!env->KickNextTick(&callback_scope)) {
if (callback_scope.in_makecallback()) {
return ret;
}
Environment::TickInfo* tick_info = env->tick_info();
if (tick_info->length() == 0) {
env->isolate()->RunMicrotasks();
}
Local<Object> process = env->process_object();
if (tick_info->length() == 0) {
tick_info->set_index(0);
}
if (env->tick_callback_function()->Call(process, 0, nullptr).IsEmpty()) {
return Undefined(env->isolate());
}

4
src/node_http_parser.cc

@ -587,8 +587,6 @@ class Parser : public AsyncWrap {
if (!cb->IsFunction())
return;
Environment::AsyncCallbackScope callback_scope(parser->env());
// Hooks for GetCurrentBuffer
parser->current_buffer_len_ = nread;
parser->current_buffer_data_ = buf->base;
@ -597,8 +595,6 @@ class Parser : public AsyncWrap {
parser->current_buffer_len_ = 0;
parser->current_buffer_data_ = nullptr;
parser->env()->KickNextTick(&callback_scope);
}

Loading…
Cancel
Save