summaryrefslogtreecommitdiff
path: root/package
diff options
context:
space:
mode:
authorMohammed Abdul Azeem <azeemmysore@gmail.com>2017-08-20 21:25:12 +0530
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2017-08-20 21:05:46 +0200
commitaff5951e7b4fa549882f4d4c4cfda99f3966a9d9 (patch)
treedbe75bc85c4320c011eca8ce3fb34431fd78474f /package
parent42009698f2ca23ea1527f0696662fbf4c23f2b84 (diff)
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@libreoffice.org> Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Diffstat (limited to 'package')
-rw-r--r--package/source/zipapi/XBufferedThreadedStream.cxx5
1 files changed, 3 insertions, 2 deletions
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 );
}
/**