diff --git a/services/backup/docker-server/contents/server/src/Reactors/server/base-reactors/ServerBidiReactorBase.h b/services/backup/docker-server/contents/server/src/Reactors/server/base-reactors/ServerBidiReactorBase.h --- a/services/backup/docker-server/contents/server/src/Reactors/server/base-reactors/ServerBidiReactorBase.h +++ b/services/backup/docker-server/contents/server/src/Reactors/server/base-reactors/ServerBidiReactorBase.h @@ -2,6 +2,7 @@ #include +#include #include #include #include @@ -25,6 +26,7 @@ : public grpc::ServerBidiReactor { Request request; Response response; + std::atomic finished = false; protected: ServerBidiReactorStatus status; @@ -70,12 +72,16 @@ this->status = ServerBidiReactorStatus( grpc::Status(grpc::StatusCode::INTERNAL, e.what())); } + if (this->finished) { + return; + } if (this->status.sendLastResponse) { this->StartWriteAndFinish( &this->response, grpc::WriteOptions(), this->status.status); } else { this->Finish(this->status.status); } + this->finished = true; } template diff --git a/services/backup/docker-server/contents/server/src/Reactors/server/base-reactors/ServerReadReactorBase.h b/services/backup/docker-server/contents/server/src/Reactors/server/base-reactors/ServerReadReactorBase.h --- a/services/backup/docker-server/contents/server/src/Reactors/server/base-reactors/ServerReadReactorBase.h +++ b/services/backup/docker-server/contents/server/src/Reactors/server/base-reactors/ServerReadReactorBase.h @@ -2,6 +2,7 @@ #include +#include #include #include #include @@ -13,6 +14,7 @@ template class ServerReadReactorBase : public grpc::ServerReadReactor { Request request; + std::atomic finished = false; void terminate(grpc::Status status); @@ -45,7 +47,11 @@ if (!this->status.ok()) { std::cout << "error: " << this->status.error_message() << std::endl; } + if (this->finished) { + return; + } this->Finish(status); + this->finished = true; } template diff --git a/services/backup/docker-server/contents/server/src/Reactors/server/base-reactors/ServerWriteReactorBase.h b/services/backup/docker-server/contents/server/src/Reactors/server/base-reactors/ServerWriteReactorBase.h --- a/services/backup/docker-server/contents/server/src/Reactors/server/base-reactors/ServerWriteReactorBase.h +++ b/services/backup/docker-server/contents/server/src/Reactors/server/base-reactors/ServerWriteReactorBase.h @@ -2,6 +2,7 @@ #include +#include #include #include #include @@ -14,6 +15,7 @@ class ServerWriteReactorBase : public grpc::ServerWriteReactor { Response response; bool initialized = false; + std::atomic finished = false; void terminate(grpc::Status status); @@ -42,7 +44,11 @@ std::cout << "error: " << this->status.error_message() << std::endl; } this->status = status; + if (this->finished) { + return; + } this->Finish(status); + this->finished = true; } template diff --git a/services/blob/src/Reactors/server/base-reactors/ServerBidiReactorBase.h b/services/blob/src/Reactors/server/base-reactors/ServerBidiReactorBase.h --- a/services/blob/src/Reactors/server/base-reactors/ServerBidiReactorBase.h +++ b/services/blob/src/Reactors/server/base-reactors/ServerBidiReactorBase.h @@ -5,6 +5,7 @@ #include #include #include +#include namespace comm { namespace network { @@ -25,6 +26,7 @@ : public grpc::ServerBidiReactor { Request request; Response response; + std::atomic finished = false; protected: ServerBidiReactorStatus status; @@ -70,12 +72,16 @@ this->status = ServerBidiReactorStatus( grpc::Status(grpc::StatusCode::INTERNAL, e.what())); } + if (this->finished) { + return; + } if (this->status.sendLastResponse) { this->StartWriteAndFinish( &this->response, grpc::WriteOptions(), this->status.status); } else { this->Finish(this->status.status); } + this->finished = true; } template diff --git a/services/blob/src/Reactors/server/base-reactors/ServerReadReactorBase.h b/services/blob/src/Reactors/server/base-reactors/ServerReadReactorBase.h --- a/services/blob/src/Reactors/server/base-reactors/ServerReadReactorBase.h +++ b/services/blob/src/Reactors/server/base-reactors/ServerReadReactorBase.h @@ -5,6 +5,7 @@ #include #include #include +#include namespace comm { namespace network { @@ -13,6 +14,7 @@ template class ServerReadReactorBase : public grpc::ServerReadReactor { Request request; + std::atomic finished = false; void terminate(grpc::Status status); @@ -45,7 +47,11 @@ if (!this->status.ok()) { std::cout << "error: " << this->status.error_message() << std::endl; } + if (this->finished) { + return; + } this->Finish(status); + this->finished = true; } template diff --git a/services/blob/src/Reactors/server/base-reactors/ServerWriteReactorBase.h b/services/blob/src/Reactors/server/base-reactors/ServerWriteReactorBase.h --- a/services/blob/src/Reactors/server/base-reactors/ServerWriteReactorBase.h +++ b/services/blob/src/Reactors/server/base-reactors/ServerWriteReactorBase.h @@ -2,6 +2,7 @@ #include +#include #include #include #include @@ -14,6 +15,7 @@ class ServerWriteReactorBase : public grpc::ServerWriteReactor { Response response; bool initialized = false; + std::atomic finished = false; void terminate(grpc::Status status); @@ -42,7 +44,11 @@ std::cout << "error: " << this->status.error_message() << std::endl; } this->status = status; + if (this->finished) { + return; + } this->Finish(status); + this->finished = true; } template