diff --git a/services/backup/docker-server/contents/server/src/Reactors/client/base-reactors/ClientBidiReactorBase.h b/services/backup/docker-server/contents/server/src/Reactors/client/base-reactors/ClientBidiReactorBase.h --- a/services/backup/docker-server/contents/server/src/Reactors/client/base-reactors/ClientBidiReactorBase.h +++ b/services/backup/docker-server/contents/server/src/Reactors/client/base-reactors/ClientBidiReactorBase.h @@ -8,6 +8,7 @@ class ClientBidiReactorBase : public grpc::ClientBidiReactor { std::shared_ptr response = nullptr; + bool terminated = false; bool done = false; bool initialized = 0; @@ -20,6 +21,7 @@ void nextWrite(); void terminate(const grpc::Status &status); + bool isTerminated(); bool isDone(); void OnWriteDone(bool ok) override; void OnReadDone(bool ok) override; @@ -63,7 +65,7 @@ if (!this->status.ok()) { std::cout << "error: " << this->status.error_message() << std::endl; } - if (this->done) { + if (this->terminated) { return; } this->terminateCallback(); @@ -73,7 +75,12 @@ this->status = grpc::Status(grpc::StatusCode::INTERNAL, e.what()); } this->StartWritesDone(); - this->done = true; + this->terminated = true; +} + +template +bool ClientBidiReactorBase::isTerminated() { + return this->terminated; } template @@ -104,6 +111,7 @@ template void ClientBidiReactorBase::OnDone( const grpc::Status &status) { + this->done = true; this->terminate(status); this->doneCallback(); } diff --git a/services/backup/docker-server/contents/server/src/Reactors/client/base-reactors/ClientReadReactorBase.h b/services/backup/docker-server/contents/server/src/Reactors/client/base-reactors/ClientReadReactorBase.h --- a/services/backup/docker-server/contents/server/src/Reactors/client/base-reactors/ClientReadReactorBase.h +++ b/services/backup/docker-server/contents/server/src/Reactors/client/base-reactors/ClientReadReactorBase.h @@ -7,12 +7,15 @@ template class ClientReadReactorBase : public grpc::ClientReadReactor { Response response; - grpc::Status status = grpc::Status::OK; bool done = false; + bool terminated = false; bool initialized = false; void terminate(const grpc::Status &status); +protected: + grpc::Status status = grpc::Status::OK; + public: Request request; grpc::ClientContext context; @@ -21,6 +24,7 @@ void OnReadDone(bool ok) override; void OnDone(const grpc::Status &status) override; bool isDone(); + bool isTerminated(); virtual std::unique_ptr readResponse(Response &response) = 0; virtual void validate(){}; @@ -37,7 +41,7 @@ if (!this->status.ok()) { std::cout << "error: " << this->status.error_message() << std::endl; } - if (this->done) { + if (this->terminated) { return; } this->terminateCallback(); @@ -46,7 +50,7 @@ } catch (std::runtime_error &e) { this->status = grpc::Status(grpc::StatusCode::INTERNAL, e.what()); } - this->done = true; + this->terminated = true; } template @@ -82,6 +86,7 @@ template void ClientReadReactorBase::OnDone( const grpc::Status &status) { + this->terminated = true; this->terminate(status); this->doneCallback(); } @@ -91,6 +96,11 @@ return this->done; } +template +bool ClientReadReactorBase::isTerminated() { + return this->terminated; +} + } // namespace reactor } // namespace network } // namespace comm diff --git a/services/backup/docker-server/contents/server/src/Reactors/client/base-reactors/ClientWriteReactorBase.h b/services/backup/docker-server/contents/server/src/Reactors/client/base-reactors/ClientWriteReactorBase.h --- a/services/backup/docker-server/contents/server/src/Reactors/client/base-reactors/ClientWriteReactorBase.h +++ b/services/backup/docker-server/contents/server/src/Reactors/client/base-reactors/ClientWriteReactorBase.h @@ -8,6 +8,7 @@ class ClientWriteReactorBase : public grpc::ClientWriteReactor { grpc::Status status = grpc::Status::OK; bool done = false; + bool terminated = false; bool initialized = 0; Request request; @@ -19,6 +20,7 @@ void OnWriteDone(bool ok) override; void terminate(const grpc::Status &status); bool isDone(); + bool isTerminated(); void OnDone(const grpc::Status &status) override; virtual std::unique_ptr prepareRequest(Request &request) = 0; @@ -64,7 +66,7 @@ if (!this->status.ok()) { std::cout << "error: " << this->status.error_message() << std::endl; } - if (this->done) { + if (this->terminated) { return; } this->terminateCallback(); @@ -73,7 +75,7 @@ } catch (std::runtime_error &e) { this->status = grpc::Status(grpc::StatusCode::INTERNAL, e.what()); } - this->done = true; + this->terminated = true; this->StartWritesDone(); } @@ -82,9 +84,15 @@ return this->done; } +template +bool ClientWriteReactorBase::isTerminated() { + return this->terminated; +} + template void ClientWriteReactorBase::OnDone( const grpc::Status &status) { + this->done = true; this->terminate(status); this->doneCallback(); }