From c980d1055e1e17da4867e3fab1ee10f604b242b0 Mon Sep 17 00:00:00 2001 From: Robin Sommer Date: Thu, 24 Oct 2013 18:16:49 -0700 Subject: [PATCH] Fix for input readers occasionally dead-locking. Bernhard and I tracked it down we believe: the thread queue could deadlock in certain cases. As a fix we tuned the heuristic for telling if a queue might have input to occasionaly err on the safe side by flagging "yes", so that processing will proceed. It's a bit unfortunate to apply this fix last minute before the release as it could potentially impact performance if the heuristic fails to often. We believe the chosen parmaterization should be fine ... --- CHANGES | 4 ++++ VERSION | 2 +- src/threading/Queue.h | 10 ++++++---- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/CHANGES b/CHANGES index 10bc187666..1ae192f293 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,8 @@ +2.2-beta-152 | 2013-10-24 18:16:49 -0700 + + * Fix for input readers occasionally dead-locking. (Robin Sommer) + 2.2-beta-151 | 2013-10-24 16:52:26 -0700 * Updating submodule(s). diff --git a/VERSION b/VERSION index 2b5702fffa..26d1beb6fe 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.2-beta-151 +2.2-beta-152 diff --git a/src/threading/Queue.h b/src/threading/Queue.h index 792fb63f9c..c4f2bfab00 100644 --- a/src/threading/Queue.h +++ b/src/threading/Queue.h @@ -61,11 +61,13 @@ public: bool Ready(); /** - * Returns true if the next Get() operation might succeed. - * This function may occasionally return a value not - * indicating the actual state, but won't do so very often. + * Returns true if the next Get() operation might succeed. This + * function may occasionally return a value not indicating the actual + * state, but won't do so very often. Occasionally we also return a + * true unconditionally to avoid a deadlock when both pointers happen + * to be equal even though there's stuff queued. */ - bool MaybeReady() { return ( ( read_ptr - write_ptr) != 0 ); } + bool MaybeReady() { return (read_ptr != write_ptr) || (random() % 10000 == 0); } /** Wake up the reader if it's currently blocked for input. This is primarily to give it a chance to check termination quickly.