diff --git a/services/backup/docker-server/contents/server/src/Reactors/server/SendLogReactor.h b/services/backup/docker-server/contents/server/src/Reactors/server/SendLogReactor.h --- a/services/backup/docker-server/contents/server/src/Reactors/server/SendLogReactor.h +++ b/services/backup/docker-server/contents/server/src/Reactors/server/SendLogReactor.h @@ -40,6 +40,7 @@ // `persistedInBlob` is false) or the holder to blob (if `persistedInBlob` is // true) std::string value; + std::mutex reactorStateMutex; std::condition_variable waitingForBlobClientCV; std::shared_ptr putReactor; @@ -86,6 +87,9 @@ std::unique_ptr SendLogReactor::readRequest(backup::SendLogRequest request) { + // we make sure that the blob client's state is flushed to the main memory + // as there may be multiple threads from the pool taking over here + const std::lock_guard lock(this->reactorStateMutex); switch (this->state) { case State::USER_ID: { if (!request.has_userid()) { @@ -142,6 +146,9 @@ } void SendLogReactor::doneCallback() { + // we make sure that the blob client's state is flushed to the main memory + // as there may be multiple threads from the pool taking over here + const std::lock_guard lock(this->reactorStateMutex); // TODO implement std::cout << "receive logs done " << this->status.error_code() << "/" << this->status.error_message() << std::endl;