From 33daee971beff4f9e0fc4eb17cd1a668a7d3ebf8 Mon Sep 17 00:00:00 2001 From: "ajohnsen@google.com" Date: Thu, 24 Oct 2013 10:24:08 +0000 Subject: [PATCH] Use while(condition) around monitor wait, in file_system_watcher_macos. This fixes a potential threading-issue, where the wacther could be used before it was fully initialized, if 'wait' woke up before notify. BUG= R=sgjesse@google.com Review URL: https://codereview.chromium.org//39713002 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@29163 260f80e4-7a28-3924-810f-c04153c831b5 --- runtime/bin/file_system_watcher_macos.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/runtime/bin/file_system_watcher_macos.cc b/runtime/bin/file_system_watcher_macos.cc index 6d51e9114ba..1ae1810f65d 100644 --- a/runtime/bin/file_system_watcher_macos.cc +++ b/runtime/bin/file_system_watcher_macos.cc @@ -136,7 +136,9 @@ class FSEventsWatcher { if (watcher == NULL) { watcher_monitor->Enter(); watcher = new FSEventsWatcher(); - watcher_monitor->Wait(Monitor::kNoTimeout); + while (watcher->run_loop_ == NULL) { + watcher_monitor->Wait(Monitor::kNoTimeout); + } watcher_monitor->Exit(); } watcher->users_++;