add mutex to scopedmemmap

This commit is contained in:
Xiao YiFang 2022-06-19 13:26:41 +08:00
parent 3c02fb7499
commit 4edd3b3987
2 changed files with 16 additions and 9 deletions

View file

@ -807,6 +807,7 @@ void FTSResultsRequest::combinedIndexSearch( BtreeIndexing::BtreeIndex & ftsInde
{
if( Utils::AtomicInt::loadAcquire( isCancelled ) )
{
Mutex::Lock _( dataMutex );
sets << tmp;
return;
}

14
mdx.cc
View file

@ -173,18 +173,24 @@ public:
return false;
}
QByteArray decompressed;
{
Mutex::Lock _( idxMutex );
ScopedMemMap compressed( mddFile, indexEntry.compressedBlockPos, indexEntry.compressedBlockSize );
if ( !compressed.startAddress() )
if( !compressed.startAddress() )
{
return false;
}
QByteArray decompressed;
if ( !MdictParser::parseCompressedBlock( indexEntry.compressedBlockSize, ( char * )compressed.startAddress(),
indexEntry.decompressedBlockSize, decompressed ) )
if( !MdictParser::parseCompressedBlock( indexEntry.compressedBlockSize,
(char *)compressed.startAddress(),
indexEntry.decompressedBlockSize,
decompressed ) )
{
return false;
}
}
result.resize( indexEntry.recordSize );
memcpy( &result.front(), decompressed.constData() + indexEntry.recordOffset, indexEntry.recordSize );