cmds: session_manager: Handle the Container Client class using pointers
We can now start the Session Manager in Stand Alone Mode. This means that the Container Manager is not required, since the assumption is that the user will provide their own container. The issue is that the container related calls are spread throughout the Session Manager's code base. So if we attempt to take an instance of the Container Client class in one if-ed out area, by the time we reach the next, it will be out of scope. One solution is to take the instance of the Container Client class globally, then only make use of it if it's required. This works great if the Container Manager is running in the background. However, since a connection is made to the Container Manager during the constructor, if the Container Manager is not running, the side-effect is the following error: Failed to connect to socket /run/anbox-container.socket: Connection refused To solve this problem we will use a global (actually private to the Session Manager) pointer which will always be in scope. It will only be initialised and used when required though. Signed-off-by: Lee Jones <lee.jones@linaro.org>
This commit is contained in:
parent
157a2f9c13
commit
e492cd1af8
2 changed files with 8 additions and 4 deletions
|
|
@ -146,9 +146,9 @@ anbox::cmds::SessionManager::SessionManager(const BusFactory &bus_factory)
|
|||
auto rt = Runtime::create();
|
||||
auto dispatcher = anbox::common::create_dispatcher_for_runtime(rt);
|
||||
|
||||
container::Client container(rt);
|
||||
if (!standalone_) {
|
||||
container.register_terminate_handler([&]() {
|
||||
container_ = std::make_shared<container::Client>(rt);
|
||||
container_->register_terminate_handler([&]() {
|
||||
WARNING("Lost connection to container manager, terminating.");
|
||||
trap->stop();
|
||||
});
|
||||
|
|
@ -237,7 +237,7 @@ anbox::cmds::SessionManager::SessionManager(const BusFactory &bus_factory)
|
|||
{"/dev/fuse", "/dev/fuse"},
|
||||
};
|
||||
|
||||
dispatcher->dispatch([&]() { container.start(container_configuration); });
|
||||
dispatcher->dispatch([&]() { container_->start(container_configuration); });
|
||||
}
|
||||
|
||||
auto bus = bus_factory_();
|
||||
|
|
@ -251,7 +251,7 @@ anbox::cmds::SessionManager::SessionManager(const BusFactory &bus_factory)
|
|||
if (!standalone_) {
|
||||
// Stop the container which should close all open connections we have on
|
||||
// our side and should terminate all services.
|
||||
container.stop();
|
||||
container_->stop();
|
||||
}
|
||||
|
||||
rt->stop();
|
||||
|
|
|
|||
|
|
@ -30,6 +30,9 @@
|
|||
#include "anbox/graphics/rect.h"
|
||||
|
||||
namespace anbox {
|
||||
namespace container {
|
||||
class Client;
|
||||
} // namespace container
|
||||
namespace cmds {
|
||||
class SessionManager : public cli::CommandWithFlagsAndAction {
|
||||
public:
|
||||
|
|
@ -40,6 +43,7 @@ class SessionManager : public cli::CommandWithFlagsAndAction {
|
|||
SessionManager(const BusFactory& bus_factory = session_bus_factory());
|
||||
|
||||
private:
|
||||
std::shared_ptr<container::Client> container_;
|
||||
BusFactory bus_factory_;
|
||||
std::string desktop_file_hint_;
|
||||
graphics::GLRendererServer::Config::Driver gles_driver_;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue