From ceb31baf9762f106f13f6a1c747b806e4f6df362 Mon Sep 17 00:00:00 2001 From: Xiao YiFang Date: Fri, 17 Jun 2022 20:23:16 +0800 Subject: [PATCH] add mutex to getBlock --- chunkedstorage.cc | 2 +- file.hh | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/chunkedstorage.cc b/chunkedstorage.cc index 33de4099..69b155fe 100644 --- a/chunkedstorage.cc +++ b/chunkedstorage.cc @@ -137,7 +137,7 @@ char * Reader::getBlock( uint32_t address, vector< char > & chunk ) // Read and decompress the chunk { // file.seek( offsets[ chunkIdx ] ); - + Mutex::Lock _( file.lock ); auto bytes = file.map( offsets[ chunkIdx ], 8 ); auto qBytes = QByteArray::fromRawData( reinterpret_cast< char * >(bytes), 8 ); QDataStream in( qBytes ); diff --git a/file.hh b/file.hh index 060c6b13..a69f3840 100644 --- a/file.hh +++ b/file.hh @@ -9,6 +9,7 @@ #include #include #include "ex.hh" +#include "mutex.hh" /// A simple wrapper over FILE * operations with added write-buffering, /// used for non-Qt parts of code. @@ -44,6 +45,7 @@ class Class void open( char const * filename, char const * mode ) ; public: + Mutex lock; Class( char const * filename, char const * mode ) ;