Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(421)

Unified Diff: tools/gn/scheduler.cc

Issue 100193002: Fix GN deadlock on error handling. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tools/gn/secondary/base/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/scheduler.cc
diff --git a/tools/gn/scheduler.cc b/tools/gn/scheduler.cc
index 254de0d5a097d6a4b5e24e8b7898de09cae33ce8..81ca60e9191a1008af829e158f056af9aae607b1 100644
--- a/tools/gn/scheduler.cc
+++ b/tools/gn/scheduler.cc
@@ -43,10 +43,16 @@ Scheduler::~Scheduler() {
bool Scheduler::Run() {
runner_.Run();
- base::AutoLock lock(lock_);
+ bool local_is_failed;
+ {
+ base::AutoLock lock(lock_);
+ local_is_failed = is_failed();
+ has_been_shutdown_ = true;
+ }
+ // Don't do this inside the lock since it will block on the workers, which
+ // may be in turn waiting on the lock.
pool_->Shutdown();
- has_been_shutdown_ = true;
- return !is_failed();
+ return !local_is_failed;
}
void Scheduler::Log(const std::string& verb, const std::string& msg) {
@@ -66,7 +72,7 @@ void Scheduler::FailWithError(const Err& err) {
{
base::AutoLock lock(lock_);
- if (is_failed_)
+ if (is_failed_ || has_been_shutdown_)
return; // Ignore errors once we see one.
is_failed_ = true;
}
« no previous file with comments | « no previous file | tools/gn/secondary/base/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698