Skip to content

Commit

Permalink
[vm] Start logging if shutdown takes too long.
Browse files Browse the repository at this point in the history
Change-Id: I2280df660cfeefe600ed7d0323769efc84ba54e3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/99738
Reviewed-by: Chinmay Garde <chinmaygarde@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
  • Loading branch information
rmacnak-google authored and commit-bot@chromium.org committed Apr 18, 2019
1 parent 2b9f968 commit 503e209
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions runtime/vm/dart.cc
Original file line number Diff line number Diff line change
Expand Up @@ -379,18 +379,41 @@ bool Dart::HasApplicationIsolateLocked() {
void Dart::WaitForApplicationIsolateShutdown() {
ASSERT(!Isolate::creation_enabled_);
MonitorLocker ml(Isolate::isolates_list_monitor_);
intptr_t num_attempts = 0;
while (HasApplicationIsolateLocked()) {
ml.Wait();
Monitor::WaitResult retval = ml.Wait(1000);
if (retval == Monitor::kTimedOut) {
num_attempts += 1;
if (num_attempts > 10) {
for (Isolate* isolate = Isolate::isolates_list_head_; isolate != NULL;
isolate = isolate->next_) {
if (!Isolate::IsVMInternalIsolate(isolate)) {
OS::PrintErr("Attempt:%" Pd " waiting for isolate %s to check in\n",
num_attempts, isolate->name_);
}
}
}
}
}
}

// This waits until only the VM isolate remains in the list.
void Dart::WaitForIsolateShutdown() {
ASSERT(!Isolate::creation_enabled_);
MonitorLocker ml(Isolate::isolates_list_monitor_);
intptr_t num_attempts = 0;
while ((Isolate::isolates_list_head_ != NULL) &&
(Isolate::isolates_list_head_->next_ != NULL)) {
ml.Wait();
Monitor::WaitResult retval = ml.Wait(1000);
if (retval == Monitor::kTimedOut) {
num_attempts += 1;
if (num_attempts > 10) {
for (Isolate* isolate = Isolate::isolates_list_head_; isolate != NULL;
isolate = isolate->next_)
OS::PrintErr("Attempt:%" Pd " waiting for isolate %s to check in\n",
num_attempts, isolate->name_);
}
}
}
ASSERT(Isolate::isolates_list_head_ == Dart::vm_isolate());
}
Expand Down

0 comments on commit 503e209

Please sign in to comment.