Just waiting 3 seconds when stop container.
If container manager dies before session manager dying, the session manager cannot exit if it waits for all. This patch fix the above issue. Signed-off-by: Han Pengfei <hanpfei@gmail.com>
This commit is contained in:
parent
5e7d773d82
commit
083b54cc2d
2 changed files with 5 additions and 1 deletions
|
|
@ -24,6 +24,9 @@
|
||||||
|
|
||||||
namespace anbox {
|
namespace anbox {
|
||||||
namespace container {
|
namespace container {
|
||||||
|
|
||||||
|
const std::chrono::milliseconds ManagementApiStub::stop_waiting_millis{3000};
|
||||||
|
|
||||||
ManagementApiStub::ManagementApiStub(
|
ManagementApiStub::ManagementApiStub(
|
||||||
const std::shared_ptr<rpc::Channel> &channel)
|
const std::shared_ptr<rpc::Channel> &channel)
|
||||||
: channel_(channel) {}
|
: channel_(channel) {}
|
||||||
|
|
@ -75,7 +78,7 @@ void ManagementApiStub::stop_container() {
|
||||||
channel_->call_method("stop_container", &message, c->response.get(),
|
channel_->call_method("stop_container", &message, c->response.get(),
|
||||||
google::protobuf::NewCallback(this, &ManagementApiStub::container_stopped, c.get()));
|
google::protobuf::NewCallback(this, &ManagementApiStub::container_stopped, c.get()));
|
||||||
|
|
||||||
c->wh.wait_for_all();
|
c->wh.wait_for_pending(stop_waiting_millis);
|
||||||
|
|
||||||
if (c->response->has_error()) throw std::runtime_error(c->response->error());
|
if (c->response->has_error()) throw std::runtime_error(c->response->error());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,7 @@ class ManagementApiStub : public DoNotCopyOrMove {
|
||||||
|
|
||||||
mutable std::mutex mutex_;
|
mutable std::mutex mutex_;
|
||||||
std::shared_ptr<rpc::Channel> channel_;
|
std::shared_ptr<rpc::Channel> channel_;
|
||||||
|
static const std::chrono::milliseconds stop_waiting_millis;
|
||||||
};
|
};
|
||||||
} // namespace container
|
} // namespace container
|
||||||
} // namespace anbox
|
} // namespace anbox
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue