From 858e7c98b0c4e8e879d341cc30e2d0f4e7983a33 Mon Sep 17 00:00:00 2001 From: heleiwang Date: Tue, 8 Sep 2020 11:40:11 +0800 Subject: [PATCH] fix delete this --- .../dataset/engine/gnn/graph_data_server.h | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/mindspore/ccsrc/minddata/dataset/engine/gnn/graph_data_server.h b/mindspore/ccsrc/minddata/dataset/engine/gnn/graph_data_server.h index cbc43654aa3..2bf1ad2b51e 100644 --- a/mindspore/ccsrc/minddata/dataset/engine/gnn/graph_data_server.h +++ b/mindspore/ccsrc/minddata/dataset/engine/gnn/graph_data_server.h @@ -89,6 +89,8 @@ class UntypedCall { virtual ~UntypedCall() {} virtual Status operator()() = 0; + + virtual bool JudgeFinish() = 0; }; template @@ -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(tag); - RETURN_IF_NOT_OK((*rq)()); + if (rq->JudgeFinish()) { + delete rq; + } else { + RETURN_IF_NOT_OK((*rq)()); + } return Status::OK(); }