summaryrefslogtreecommitdiff
path: root/src/env.cc
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2017-09-25 22:53:17 +0200
committerAnna Henningsen <anna@addaleax.net>2018-05-10 14:15:16 +0200
commit1db0039c505c6081f1d0d84cc24133ed6659e539 (patch)
treef6eab3adfb959b735d274f6c83790ef83834a21b /src/env.cc
parentcac8496c2ff592198a7afd114610deccb0e178ab (diff)
downloadnode-new-1db0039c505c6081f1d0d84cc24133ed6659e539.tar.gz
src: keep track of open requests
Workers cannot shut down while requests are open, so keep a counter that is increased whenever libuv requests are made and decreased whenever their callback is called. This also applies to other embedders, who may want to shut down an `Environment` instance early. Many thanks for Stephen Belanger for reviewing the original version of this commit in the Ayo.js project. Fixes: https://github.com/nodejs/node/issues/20517 Refs: https://github.com/ayojs/ayo/pull/85 PR-URL: https://github.com/nodejs/node/pull/19377 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src/env.cc')
-rw-r--r--src/env.cc6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/env.cc b/src/env.cc
index 6526c680ac..e5b9c0fd6a 100644
--- a/src/env.cc
+++ b/src/env.cc
@@ -107,7 +107,6 @@ Environment::Environment(IsolateData* isolate_data,
#if HAVE_INSPECTOR
inspector_agent_(new inspector::Agent(this)),
#endif
- handle_cleanup_waiting_(0),
http_parser_buffer_(nullptr),
fs_stats_field_array_(isolate_, kFsStatsFieldsLength * 2),
context_(context->GetIsolate(), context) {
@@ -241,8 +240,11 @@ void Environment::CleanupHandles() {
hc.cb_(this, hc.handle_, hc.arg_);
handle_cleanup_queue_.clear();
- while (handle_cleanup_waiting_ != 0 || !handle_wrap_queue_.IsEmpty())
+ while (handle_cleanup_waiting_ != 0 ||
+ request_waiting_ != 0 ||
+ !handle_wrap_queue_.IsEmpty()) {
uv_run(event_loop(), UV_RUN_ONCE);
+ }
}
void Environment::StartProfilerIdleNotifier() {