Commit ca7b8322 by Tianqi Chen Committed by GitHub

[RPC] safe destructor when remote server get killed (#1086)

parent d949c742
...@@ -34,8 +34,12 @@ class RPCDeviceAPI final : public DeviceAPI { ...@@ -34,8 +34,12 @@ class RPCDeviceAPI final : public DeviceAPI {
} }
void FreeDataSpace(TVMContext ctx, void* ptr) final { void FreeDataSpace(TVMContext ctx, void* ptr) final {
RemoteSpace* space = static_cast<RemoteSpace*>(ptr); RemoteSpace* space = static_cast<RemoteSpace*>(ptr);
GetSess(ctx)->CallRemote( try {
RPCCode::kDevFreeData, ctx, space->data); GetSess(ctx)->CallRemote(
RPCCode::kDevFreeData, ctx, space->data);
} catch (const dmlc::Error& e) {
// fault tolerance to remote close.
}
delete space; delete space;
} }
void CopyDataFromTo(const void* from, void CopyDataFromTo(const void* from,
......
...@@ -26,7 +26,11 @@ struct RPCWrappedFunc { ...@@ -26,7 +26,11 @@ struct RPCWrappedFunc {
sess_->CallFunc(handle_, args, rv, &fwrap_); sess_->CallFunc(handle_, args, rv, &fwrap_);
} }
~RPCWrappedFunc() { ~RPCWrappedFunc() {
sess_->CallRemote(RPCCode::kFreeFunc, handle_); try {
sess_->CallRemote(RPCCode::kFreeFunc, handle_);
} catch (const dmlc::Error& e) {
// fault tolerance to remote close
}
} }
static void WrapRemote(std::shared_ptr<RPCSession> sess, static void WrapRemote(std::shared_ptr<RPCSession> sess,
...@@ -48,7 +52,11 @@ class RPCModuleNode final : public ModuleNode { ...@@ -48,7 +52,11 @@ class RPCModuleNode final : public ModuleNode {
} }
~RPCModuleNode() { ~RPCModuleNode() {
if (module_handle_ != nullptr) { if (module_handle_ != nullptr) {
sess_->CallRemote(RPCCode::kModuleFree, module_handle_); try {
sess_->CallRemote(RPCCode::kModuleFree, module_handle_);
} catch (const dmlc::Error& e) {
// fault tolerance to remote close
}
module_handle_ = nullptr; module_handle_ = nullptr;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment