[Libreoffice-commits] core.git: package/source
Mohammed Abdul Azeem
azeemmysore at gmail.com
Sun Aug 20 19:07:50 UTC 2017
package/source/zipapi/XBufferedThreadedStream.cxx | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
New commits:
commit aff5951e7b4fa549882f4d4c4cfda99f3966a9d9
Author: Mohammed Abdul Azeem <azeemmysore at gmail.com>
Date: Sun Aug 20 21:25:12 2017 +0530
Fixing threadedStream produce loop condition:
hasBytes() is for the consuming thread, produce loop should
be stopped as soon as we've read as much as size of the stream.
Change-Id: I0d857cc9cbcc4dd7d4a43cddbc4c457e8280353f
Reviewed-on: https://gerrit.libreoffice.org/41364
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
diff --git a/package/source/zipapi/XBufferedThreadedStream.cxx b/package/source/zipapi/XBufferedThreadedStream.cxx
index c7fd3dbacd36..11428e076d44 100644
--- a/package/source/zipapi/XBufferedThreadedStream.cxx
+++ b/package/source/zipapi/XBufferedThreadedStream.cxx
@@ -76,6 +76,7 @@ XBufferedThreadedStream::~XBufferedThreadedStream()
void XBufferedThreadedStream::produce()
{
Buffer pProducedBuffer;
+ sal_Int64 nTotalBytesRead(0);
std::unique_lock<std::mutex> aGuard( maBufferProtector );
do
{
@@ -86,7 +87,7 @@ void XBufferedThreadedStream::produce()
}
aGuard.unlock();
- mxSrcStream->readBytes( pProducedBuffer, nBufferSize );
+ nTotalBytesRead += mxSrcStream->readBytes( pProducedBuffer, nBufferSize );
aGuard.lock();
maPendingBuffers.push( pProducedBuffer );
@@ -95,7 +96,7 @@ void XBufferedThreadedStream::produce()
if (!mbTerminateThread)
maBufferProduceResume.wait( aGuard, [&]{return canProduce(); } );
- } while( !mbTerminateThread && hasBytes() );
+ } while( !mbTerminateThread && nTotalBytesRead < mnStreamSize );
}
/**
More information about the Libreoffice-commits
mailing list