bridge: use five second timeout for all RPC
Before we were waiting forever for a reply which never occured in some cases due to errors when processing incoming protobuf messages we now abort the RPC call after a timeout of five seconds to keep operational.
This commit is contained in:
parent
f76c039415
commit
8237c963ed
1 changed files with 16 additions and 4 deletions
|
|
@ -29,6 +29,10 @@
|
|||
|
||||
namespace fs = boost::filesystem;
|
||||
|
||||
namespace {
|
||||
constexpr const std::chrono::milliseconds default_rpc_call_timeout{5000};
|
||||
} // namespace
|
||||
|
||||
namespace anbox {
|
||||
namespace bridge {
|
||||
AndroidApiStub::AndroidApiStub() {}
|
||||
|
|
@ -103,7 +107,9 @@ void AndroidApiStub::launch(const android::Intent &intent,
|
|||
google::protobuf::NewCallback(this, &AndroidApiStub::application_launched,
|
||||
c.get()));
|
||||
|
||||
launch_wait_handle_.wait_for_all();
|
||||
launch_wait_handle_.wait_for_pending(default_rpc_call_timeout);
|
||||
if (!launch_wait_handle_.has_result())
|
||||
throw std::runtime_error("RPC call timed out");
|
||||
|
||||
if (c->response->has_error()) throw std::runtime_error(c->response->error());
|
||||
}
|
||||
|
|
@ -135,7 +141,9 @@ void AndroidApiStub::set_focused_task(const std::int32_t &id) {
|
|||
google::protobuf::NewCallback(
|
||||
this, &AndroidApiStub::focused_task_set, c.get()));
|
||||
|
||||
set_focused_task_handle_.wait_for_all();
|
||||
set_focused_task_handle_.wait_for_pending(default_rpc_call_timeout);
|
||||
if (!set_focused_task_handle_.has_result())
|
||||
throw std::runtime_error("RPC call timed out");
|
||||
|
||||
if (c->response->has_error()) throw std::runtime_error(c->response->error());
|
||||
}
|
||||
|
|
@ -162,7 +170,9 @@ void AndroidApiStub::remove_task(const std::int32_t &id) {
|
|||
google::protobuf::NewCallback(
|
||||
this, &AndroidApiStub::task_removed, c.get()));
|
||||
|
||||
remove_task_handle_.wait_for_all();
|
||||
remove_task_handle_.wait_for_pending(default_rpc_call_timeout);
|
||||
if (!remove_task_handle_.has_result())
|
||||
throw std::runtime_error("RPC call timed out");
|
||||
|
||||
if (c->response->has_error()) throw std::runtime_error(c->response->error());
|
||||
}
|
||||
|
|
@ -198,7 +208,9 @@ void AndroidApiStub::resize_task(const std::int32_t &id,
|
|||
google::protobuf::NewCallback(
|
||||
this, &AndroidApiStub::task_resized, c.get()));
|
||||
|
||||
resize_task_handle_.wait_for_all();
|
||||
resize_task_handle_.wait_for_pending(default_rpc_call_timeout);
|
||||
if (!resize_task_handle_.has_result())
|
||||
throw std::runtime_error("RPC call timed out");
|
||||
|
||||
if (c->response->has_error()) throw std::runtime_error(c->response->error());
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue