diff options
author | Brad King <brad.king@kitware.com> | 2019-03-26 14:59:48 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2019-03-26 14:59:57 (GMT) |
commit | f288383b3ff3f1c095ecefc41e53a638f76e9744 (patch) | |
tree | e1aa3236473d5a4886b12badc20897ff2330cc88 | |
parent | ba55fc2aa5f80efb49f53eba2bf8f2e1d2b6899a (diff) | |
parent | e7a760fe7d20b5c3da53e2daa415ac09865da78c (diff) | |
download | CMake-f288383b3ff3f1c095ecefc41e53a638f76e9744.zip CMake-f288383b3ff3f1c095ecefc41e53a638f76e9744.tar.gz CMake-f288383b3ff3f1c095ecefc41e53a638f76e9744.tar.bz2 |
Merge topic 'fix_autogen_deadlock'
e7a760fe7d Autogen: Fix deadlock when uv_spawn() fails while trying to run moc
Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: Sebastian Holtermann <sebholt@xwmw.org>
Merge-request: !3139
-rw-r--r-- | Source/cmQtAutoGenerator.cxx | 14 | ||||
-rw-r--r-- | Source/cmQtAutoGeneratorMocUic.cxx | 6 |
2 files changed, 17 insertions, 3 deletions
diff --git a/Source/cmQtAutoGenerator.cxx b/Source/cmQtAutoGenerator.cxx index a1abd3f..27afe48 100644 --- a/Source/cmQtAutoGenerator.cxx +++ b/Source/cmQtAutoGenerator.cxx @@ -15,6 +15,7 @@ #include "cmake.h" #include <algorithm> +#include <sstream> #include <utility> // -- Class methods @@ -504,6 +505,13 @@ void cmQtAutoGenerator::ReadOnlyProcessT::setup( Setup_.MergedOutput = mergedOutput; } +static std::string getUVError(const char* prefixString, int uvErrorCode) +{ + std::ostringstream ost; + ost << prefixString << ": " << uv_strerror(uvErrorCode); + return ost.str(); +} + bool cmQtAutoGenerator::ReadOnlyProcessT::start( uv_loop_t* uv_loop, std::function<void()>&& finishedCallback) { @@ -560,8 +568,10 @@ bool cmQtAutoGenerator::ReadOnlyProcessT::start( UVOptions_.stdio = UVOptionsStdIO_.data(); // -- Spawn process - if (UVProcess_.spawn(*uv_loop, UVOptions_, this) != 0) { - Result()->ErrorMessage = "libuv process spawn failed"; + int uvErrorCode = UVProcess_.spawn(*uv_loop, UVOptions_, this); + if (uvErrorCode != 0) { + Result()->ErrorMessage = + getUVError("libuv process spawn failed ", uvErrorCode); } } // -- Start reading from stdio streams diff --git a/Source/cmQtAutoGeneratorMocUic.cxx b/Source/cmQtAutoGeneratorMocUic.cxx index cb6f7ea..0982473 100644 --- a/Source/cmQtAutoGeneratorMocUic.cxx +++ b/Source/cmQtAutoGeneratorMocUic.cxx @@ -1107,13 +1107,17 @@ void cmQtAutoGeneratorMocUic::WorkerT::UVProcessStart(uv_async_t* handle) wrk.Process_->start(handle->loop, [&wrk] { wrk.UVProcessFinished(); }); } } + + if (!wrk.Process_->IsStarted()) { + wrk.UVProcessFinished(); + } } void cmQtAutoGeneratorMocUic::WorkerT::UVProcessFinished() { { std::lock_guard<std::mutex> lock(ProcessMutex_); - if (Process_ && Process_->IsFinished()) { + if (Process_ && (Process_->IsFinished() || !Process_->IsStarted())) { Process_.reset(); } } |