Skip to content

Commit cadc820

Browse files
committed
add gzfile init mutex lock
Signed-off-by: zhuangbowei.zbw <zhuangbowei.zbw@alibaba-inc.com>
1 parent 83b7bb8 commit cadc820

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/overlaybd/gzindex/gzfile.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "photon/photon.h"
2929
#include "photon/fs/virtual-file.h"
3030
#include "photon/common/checksum/crc32c.h"
31+
#include "photon/thread/thread.h"
3132

3233
namespace FileSystem {
3334
using namespace photon::fs;
@@ -62,6 +63,7 @@ class GzFile : public VirtualReadOnlyFile {
6263
struct IndexFileHeader index_header_;
6364
INDEX index_;
6465
bool inited_ = false;
66+
photon::mutex init_mutex_;
6567
int init();
6668
int parse_index();
6769
IndexEntry *seek_index(INDEX &index, off_t offset);
@@ -142,6 +144,7 @@ int GzFile::parse_index() {
142144
}
143145

144146
int GzFile::init() {
147+
SCOPED_LOCK(init_mutex_);
145148
if (inited_) {
146149
return 0;
147150
}

0 commit comments

Comments
 (0)