| @@ -26,14 +26,19 @@ void TdtHandle::AddHandle(acltdtChannelHandle *handle) { | |||||
| } | } | ||||
| bool TdtHandle::DestroyHandle() { | bool TdtHandle::DestroyHandle() { | ||||
| for (auto handle : acl_handle) { | |||||
| bool destroy_all = true; | |||||
| for (auto &handle : acl_handle) { | |||||
| if (handle != nullptr) { | if (handle != nullptr) { | ||||
| if (acltdtDestroyChannel(handle) != ACL_SUCCESS) { | if (acltdtDestroyChannel(handle) != ACL_SUCCESS) { | ||||
| return false; | |||||
| destroy_all = false; | |||||
| } else { | |||||
| handle = nullptr; | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| return true; | |||||
| return destroy_all; | |||||
| } | } | ||||
| std::vector<acltdtChannelHandle *> TdtHandle::GetHandle() { return acl_handle; } | |||||
| } // namespace dataset | } // namespace dataset | ||||
| } // namespace mindspore | } // namespace mindspore | ||||
| @@ -28,6 +28,8 @@ class TdtHandle { | |||||
| static bool DestroyHandle(); | static bool DestroyHandle(); | ||||
| static std::vector<acltdtChannelHandle *> GetHandle(); | |||||
| private: | private: | ||||
| TdtHandle() {} | TdtHandle() {} | ||||
| @@ -33,8 +33,11 @@ TdtPlugin::TdtPlugin(const std::string &channel_name, int32_t device_id) { | |||||
| } | } | ||||
| TdtPlugin::~TdtPlugin() { | TdtPlugin::~TdtPlugin() { | ||||
| if (acl_handle_ != nullptr && acltdtDestroyChannel(acl_handle_) != ACL_SUCCESS) { | |||||
| MS_LOG(ERROR) << "Failed to destroy channel for tdt queue."; | |||||
| std::vector<acltdtChannelHandle *> total_handle = TdtHandle::GetHandle(); | |||||
| if (std::find(total_handle.begin(), total_handle.end(), acl_handle_) != total_handle.end()) { | |||||
| if (acl_handle_ != nullptr && acltdtDestroyChannel(acl_handle_) != ACL_SUCCESS) { | |||||
| MS_LOG(ERROR) << "Failed to destroy channel for tdt queue."; | |||||
| } | |||||
| } | } | ||||
| } | } | ||||