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 {
}
void FreeDataSpace(TVMContext ctx, void* ptr) final {
RemoteSpace* space = static_cast<RemoteSpace*>(ptr);
try {
GetSess(ctx)->CallRemote(
RPCCode::kDevFreeData, ctx, space->data);
} catch (const dmlc::Error& e) {
// fault tolerance to remote close.
}
delete space;
}
void CopyDataFromTo(const void* from,
......
......@@ -26,7 +26,11 @@ struct RPCWrappedFunc {
sess_->CallFunc(handle_, args, rv, &fwrap_);
}
~RPCWrappedFunc() {
try {
sess_->CallRemote(RPCCode::kFreeFunc, handle_);
} catch (const dmlc::Error& e) {
// fault tolerance to remote close
}
}
static void WrapRemote(std::shared_ptr<RPCSession> sess,
......@@ -48,7 +52,11 @@ class RPCModuleNode final : public ModuleNode {
}
~RPCModuleNode() {
if (module_handle_ != nullptr) {
try {
sess_->CallRemote(RPCCode::kModuleFree, module_handle_);
} catch (const dmlc::Error& e) {
// fault tolerance to remote close
}
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