From 73d4b0034334d798ca0ee935d7f60792e1ac8649 Mon Sep 17 00:00:00 2001 From: Jesse Lee Date: Fri, 24 Jul 2020 13:06:19 -0400 Subject: [PATCH] Fix infinite loop for cache server thread --- mindspore/ccsrc/minddata/dataset/util/service.cc | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/mindspore/ccsrc/minddata/dataset/util/service.cc b/mindspore/ccsrc/minddata/dataset/util/service.cc index 19d60ab47..d7e1e02e6 100644 --- a/mindspore/ccsrc/minddata/dataset/util/service.cc +++ b/mindspore/ccsrc/minddata/dataset/util/service.cc @@ -34,7 +34,18 @@ Status Service::ServiceStart() { state_ = STATE::kStartInProg; // At this point, we will let go of the lock. This allow others to proceed. lck.Unlock(); - RETURN_IF_NOT_OK(DoServiceStart()); + // Call the real implementation from the derived class. + Status rc = DoServiceStart(); + // If we hit any error, change the state back into the initial state. + // It is possible that the user may want to drive a clean up by calling + // ServiceStop but if it will end up in a loop because of the state is still + // kStartInProg. + if (rc.IsError()) { + lck.Lock(); + state_ = STATE::kStopped; + lck.Unlock(); + return rc; + } // Lock again to change state. lck.Lock(); state_ = STATE::kRunning; -- GitLab