Index: runtime/vm/dart.cc |
diff --git a/runtime/vm/dart.cc b/runtime/vm/dart.cc |
index fe8154ba764df85f7f94087b1ea3eb2a43438ceb..9364bb98fb94aeebc4f3ddabeaf6dbc21ffe3ee4 100644 |
--- a/runtime/vm/dart.cc |
+++ b/runtime/vm/dart.cc |
@@ -310,6 +310,21 @@ char* Dart::InitOnce(const uint8_t* vm_isolate_snapshot, |
} |
+// This waits until only the VM isolate and the service isolate remains in the |
+// list, i.e. list length == 2. |
+void Dart::WaitForApplicationIsolateShutdown() { |
+ ASSERT(!Isolate::creation_enabled_); |
+ MonitorLocker ml(Isolate::isolates_list_monitor_); |
+ while ((Isolate::isolates_list_head_ != NULL) && |
+ (Isolate::isolates_list_head_->next_ != NULL) && |
+ (Isolate::isolates_list_head_->next_->next_ != NULL)) { |
+ ml.Wait(); |
+ } |
+ ASSERT(Isolate::isolates_list_head_ == Dart::vm_isolate()); |
zra
2016/06/10 21:51:07
Is the VM isolate really guaranteed to be first?
Florian Schneider
2016/06/10 21:53:05
good point. I have to fix this assertion.
|
+ ASSERT(ServiceIsolate::IsServiceIsolate(Isolate::isolates_list_head_->next_)); |
+} |
+ |
+ |
// This waits until only the VM isolate remains in the list. |
void Dart::WaitForIsolateShutdown() { |
ASSERT(!Isolate::creation_enabled_); |
@@ -371,6 +386,13 @@ const char* Dart::Cleanup() { |
} |
Isolate::KillAllIsolates(Isolate::kInternalKillMsg); |
+ // Wait for all isolates, but the service and the vm isolate to shut down. |
+ if (FLAG_trace_shutdown) { |
+ OS::PrintErr("[+%" Pd64 "ms] SHUTDOWN: Shutting down app isolates\n", |
+ timestamp()); |
+ } |
+ WaitForApplicationIsolateShutdown(); |
+ |
// Shutdown the service isolate. |
if (FLAG_trace_shutdown) { |
OS::PrintErr("[+%" Pd64 "ms] SHUTDOWN: Shutting down service isolate\n", |
@@ -378,7 +400,7 @@ const char* Dart::Cleanup() { |
} |
ServiceIsolate::Shutdown(); |
- // Wait for all application isolates and the service isolate to shutdown |
+ // Wait for the remaining isolate (service isolate) to shutdown |
// before shutting down the thread pool. |
if (FLAG_trace_shutdown) { |
OS::PrintErr("[+%" Pd64 "ms] SHUTDOWN: Waiting for isolate shutdown\n", |