Kaydet (Commit) aff5951e authored tarafından Mohammed Abdul Azeem's avatar Mohammed Abdul Azeem Kaydeden (comit) Markus Mohrhard

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/41364Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMarkus Mohrhard <markus.mohrhard@googlemail.com>
üst 42009698
......@@ -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 );
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment