Skip to content

Commit 12bac2c

Browse files
MrLolthe1stblinkov
authored andcommitted
Fix QPlayer
commit_hash:baf8d5770985eb68e94541ff6b1852b38cddc181
1 parent 228cdec commit 12bac2c

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

yql/essentials/core/qplayer/storage/interface/yql_qstorage.cpp

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,15 @@ class TQWriterDecorator : public IQWriter {
77
public:
88
TQWriterDecorator(IQWriterPtr&& underlying) : Underlying_(std::move(underlying)) {}
99
NThreading::TFuture<void> Put(const TQItemKey& key, const TString& value) override final {
10+
decltype(Underlying_) underlying;
11+
with_lock(Mutex_) {
12+
underlying = Underlying_;
13+
}
1014
if (Closed_) {
1115
return NThreading::MakeFuture();
1216
}
1317
try {
14-
return Underlying_->Put(key, value);
18+
return underlying->Put(key, value);
1519
} catch (...) {
1620
auto message = CurrentExceptionMessage();
1721
with_lock(Mutex_) {
@@ -32,16 +36,24 @@ class TQWriterDecorator : public IQWriter {
3236
if (!Closed_.compare_exchange_strong(expected, true)) {
3337
throw yexception() << "QWriter closed";
3438
}
35-
auto result = Underlying_->Commit();
36-
Underlying_ = {};
39+
decltype(Underlying_) underlying;
40+
with_lock(Mutex_) {
41+
underlying = Underlying_;
42+
}
43+
auto result = underlying->Commit();
44+
with_lock(Mutex_) {
45+
Underlying_ = {};
46+
}
3747
return result;
3848
}
3949

4050
// Close all used files, doesn't commit anything
4151
void Close() override final {
4252
bool expected = false;
4353
if (Closed_.compare_exchange_strong(expected, true)) {
44-
Underlying_ = {};
54+
with_lock(Mutex_) {
55+
Underlying_ = {};
56+
}
4557
}
4658
}
4759
private:

0 commit comments

Comments
 (0)