summaryrefslogtreecommitdiff
path: root/src/lib/j2k_encoder.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/j2k_encoder.cc')
-rw-r--r--src/lib/j2k_encoder.cc10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/lib/j2k_encoder.cc b/src/lib/j2k_encoder.cc
index 7c9777c16..32d2fefc2 100644
--- a/src/lib/j2k_encoder.cc
+++ b/src/lib/j2k_encoder.cc
@@ -69,6 +69,16 @@ J2KEncoder::~J2KEncoder ()
{
_server_found_connection.disconnect();
+ /* One of our encoder threads may be waiting on Writer::write() to return, if that method
+ * is blocked with the writer queue full waiting for _full_condition. In that case, the
+ * attempt to terminate the encoder threads below (in terminate_threads()) will fail because
+ * the encoder thread waiting for ::write() will have interruption disabled.
+ *
+ * To work around that, make the writer into a zombie to unblock any pending write()s and
+ * not block on any future ones.
+ */
+ _writer.zombify();
+
boost::mutex::scoped_lock lm (_threads_mutex);
terminate_threads ();
}