Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3377221
D3664.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
6 KB
Referenced Files
None
Subscribers
None
D3664.diff
View Options
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 <grpcpp/grpcpp.h>
+#include <atomic>
#include <iostream>
#include <memory>
#include <string>
@@ -25,6 +26,7 @@
: public grpc::ServerBidiReactor<Request, Response> {
Request request;
Response response;
+ std::atomic<bool> 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 <class Request, class Response>
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 <grpcpp/grpcpp.h>
+#include <atomic>
#include <iostream>
#include <memory>
#include <string>
@@ -13,6 +14,7 @@
template <class Request, class Response>
class ServerReadReactorBase : public grpc::ServerReadReactor<Request> {
Request request;
+ std::atomic<bool> 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 <class Request, class Response>
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 <grpcpp/grpcpp.h>
+#include <atomic>
#include <iostream>
#include <memory>
#include <string>
@@ -14,6 +15,7 @@
class ServerWriteReactorBase : public grpc::ServerWriteReactor<Response> {
Response response;
bool initialized = false;
+ std::atomic<bool> 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 <class Request, class Response>
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 <iostream>
#include <memory>
#include <string>
+#include <atomic>
namespace comm {
namespace network {
@@ -25,6 +26,7 @@
: public grpc::ServerBidiReactor<Request, Response> {
Request request;
Response response;
+ std::atomic<bool> 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 <class Request, class Response>
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 <iostream>
#include <memory>
#include <string>
+#include <atomic>
namespace comm {
namespace network {
@@ -13,6 +14,7 @@
template <class Request, class Response>
class ServerReadReactorBase : public grpc::ServerReadReactor<Request> {
Request request;
+ std::atomic<bool> 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 <class Request, class Response>
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 <grpcpp/grpcpp.h>
+#include <atomic>
#include <iostream>
#include <memory>
#include <string>
@@ -14,6 +15,7 @@
class ServerWriteReactorBase : public grpc::ServerWriteReactor<Response> {
Response response;
bool initialized = false;
+ std::atomic<bool> 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 <class Request, class Response>
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Nov 28, 4:30 AM (21 h, 56 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2592767
Default Alt Text
D3664.diff (6 KB)
Attached To
Mode
D3664: [services] Backup/Blob - Make sure Finish is only called once
Attached
Detach File
Event Timeline
Log In to Comment