提交 65c5663c 编写于 作者: M mindspore-ci-bot 提交者: Gitee

!5886 fix use “delete this” in graph_data_server.h

Merge pull request !5886 from heleiwang/fix_delete_this
......@@ -89,6 +89,8 @@ class UntypedCall {
virtual ~UntypedCall() {}
virtual Status operator()() = 0;
virtual bool JudgeFinish() = 0;
};
template <class ServiceImpl, class AsyncService, class RequestMessage, class ResponseMessage>
......@@ -120,23 +122,29 @@ class CallData : public UntypedCall {
return Status::OK();
}
Status operator()() {
Status operator()() override {
if (status_ == STATE::CREATE) {
status_ = STATE::PROCESS;
(async_service_->*enqueue_function_)(&ctx_, &request_, &responder_, cq_, cq_, this);
} else if (status_ == STATE::PROCESS) {
EnqueueRequest(service_impl_, async_service_, cq_, enqueue_function_, handle_request_function_);
status_ = STATE::FINISH;
// new CallData(service_, cq_, this->s_type_);
grpc::Status s = (service_impl_->*handle_request_function_)(&ctx_, &request_, &response_);
responder_.Finish(response_, s, this);
} else {
GPR_ASSERT(status_ == STATE::FINISH);
delete this;
MS_LOG(WARNING) << "The CallData status is finish and the pointer needs to be released.";
}
return Status::OK();
}
bool JudgeFinish() override {
if (status_ == STATE::FINISH) {
return true;
} else {
return false;
}
}
private:
STATE status_;
ServiceImpl *service_impl_;
......@@ -183,7 +191,11 @@ class GraphDataGrpcServer : public GrpcAsyncServer {
Status ProcessRequest(void *tag) {
auto rq = static_cast<UntypedCall *>(tag);
RETURN_IF_NOT_OK((*rq)());
if (rq->JudgeFinish()) {
delete rq;
} else {
RETURN_IF_NOT_OK((*rq)());
}
return Status::OK();
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册