We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 83b7bb8 commit cadc820Copy full SHA for cadc820
src/overlaybd/gzindex/gzfile.cpp
@@ -28,6 +28,7 @@
28
#include "photon/photon.h"
29
#include "photon/fs/virtual-file.h"
30
#include "photon/common/checksum/crc32c.h"
31
+#include "photon/thread/thread.h"
32
33
namespace FileSystem {
34
using namespace photon::fs;
@@ -62,6 +63,7 @@ class GzFile : public VirtualReadOnlyFile {
62
63
struct IndexFileHeader index_header_;
64
INDEX index_;
65
bool inited_ = false;
66
+ photon::mutex init_mutex_;
67
int init();
68
int parse_index();
69
IndexEntry *seek_index(INDEX &index, off_t offset);
@@ -142,6 +144,7 @@ int GzFile::parse_index() {
142
144
}
143
145
146
int GzFile::init() {
147
+ SCOPED_LOCK(init_mutex_);
148
if (inited_) {
149
return 0;
150
0 commit comments