diff --git a/package/source/zipapi/XBufferedThreadedStream.cxx b/package/source/zipapi/XBufferedThreadedStream.cxx index b8ae6e644e25..990844af0bd7 100644 --- a/package/source/zipapi/XBufferedThreadedStream.cxx +++ b/package/source/zipapi/XBufferedThreadedStream.cxx @@ -90,12 +90,11 @@ void XBufferedThreadedStream::produce() aGuard.lock(); maPendingBuffers.push( pProducedBuffer ); maBufferConsumeResume.notify_one(); - maBufferProduceResume.wait( aGuard, [&]{return canProduce(); } ); - if( mbTerminateThread ) - break; + if (!mbTerminateThread) + maBufferProduceResume.wait( aGuard, [&]{return canProduce(); } ); - } while( hasBytes() ); + } while( !mbTerminateThread && hasBytes() ); } /** @@ -134,6 +133,7 @@ const Buffer& XBufferedThreadedStream::getNextBlock() void XBufferedThreadedStream::setTerminateThread() { + std::unique_lock aGuard( maBufferProtector ); mbTerminateThread = true; maBufferProduceResume.notify_one(); maBufferConsumeResume.notify_one();