[Libreoffice-commits] core.git: package/source

Michael Meeks michael.meeks at collabora.com
Tue Jun 13 14:06:54 UTC 2017


 package/source/zipapi/XBufferedThreadedStream.cxx |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

New commits:
commit c573a10a6a873af11c25fef59a374a37fe76056f
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Tue Jun 13 13:41:15 2017 +0100

    Avoid race between mbTerminate check and wait.
    
            package2.dll!osl::Thread::join() Line 112       C++
            package2.dll!XBufferedThreadedStream::~XBufferedThreadedStream() Line 68        C++
            package2.dll!XBufferedThreadedStream::`scalar deleting destructor'(unsigned int)        C++
    vs.
            package2.dll!std::condition_variable::wait<bool <lambda>(void) >...
            package2.dll!XBufferedThreadedStream::produce() Line 95 C++
            package2.dll!`anonymous namespace'::UnzippingThread::execute() Line 29  C++
    
    Change-Id: Iace86efc5e7fe00a5176380a8a21b2dc5e98d8a5
    Reviewed-on: https://gerrit.libreoffice.org/38737
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>

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<std::mutex> aGuard( maBufferProtector );
     mbTerminateThread = true;
     maBufferProduceResume.notify_one();
     maBufferConsumeResume.notify_one();


More information about the Libreoffice-commits mailing list