mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-23 15:32:25 +00:00
Abandon Init::Traditional_child_policy, fix #1449
This commit is contained in:
parent
d312f840bd
commit
2ddf941660
@ -28,8 +28,23 @@
|
|||||||
|
|
||||||
#include <init/child.h>
|
#include <init/child.h>
|
||||||
|
|
||||||
class Launchpad_child_policy : public Init::Traditional_child_policy
|
class Launchpad_child_policy : public Genode::Child_policy,
|
||||||
|
public Genode::Client
|
||||||
{
|
{
|
||||||
|
private:
|
||||||
|
|
||||||
|
typedef Genode::String<64> Name;
|
||||||
|
Name const _name;
|
||||||
|
|
||||||
|
Genode::Server *_server;
|
||||||
|
Genode::Service_registry *_parent_services;
|
||||||
|
Genode::Service_registry *_child_services;
|
||||||
|
Genode::Dataspace_capability _config_ds;
|
||||||
|
Genode::Rpc_entrypoint *_parent_entrypoint;
|
||||||
|
Init::Child_policy_enforce_labeling _labeling_policy;
|
||||||
|
Init::Child_policy_provide_rom_file _config_policy;
|
||||||
|
Init::Child_policy_provide_rom_file _binary_policy;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Launchpad_child_policy(const char *name,
|
Launchpad_child_policy(const char *name,
|
||||||
@ -40,11 +55,19 @@ class Launchpad_child_policy : public Init::Traditional_child_policy
|
|||||||
Genode::Dataspace_capability binary_ds,
|
Genode::Dataspace_capability binary_ds,
|
||||||
Genode::Rpc_entrypoint *parent_entrypoint)
|
Genode::Rpc_entrypoint *parent_entrypoint)
|
||||||
:
|
:
|
||||||
Init::Traditional_child_policy(name, server, parent_services,
|
_name(name),
|
||||||
child_services, config_ds,
|
_server(server),
|
||||||
binary_ds, 0, 0, 0, parent_entrypoint)
|
_parent_services(parent_services),
|
||||||
|
_child_services(child_services),
|
||||||
|
_config_ds(config_ds),
|
||||||
|
_parent_entrypoint(parent_entrypoint),
|
||||||
|
_labeling_policy(_name.string()),
|
||||||
|
_config_policy("config", config_ds, _parent_entrypoint),
|
||||||
|
_binary_policy("binary", binary_ds, _parent_entrypoint)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
|
const char *name() const { return _name.string(); }
|
||||||
|
|
||||||
Genode::Service *resolve_session_request(const char *service_name,
|
Genode::Service *resolve_session_request(const char *service_name,
|
||||||
const char *args)
|
const char *args)
|
||||||
{
|
{
|
||||||
@ -86,6 +109,38 @@ class Launchpad_child_policy : public Init::Traditional_child_policy
|
|||||||
return _child_services->wait_for_service(service_name,
|
return _child_services->wait_for_service(service_name,
|
||||||
&client, name());
|
&client, name());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void filter_session_args(const char *service, char *args,
|
||||||
|
Genode::size_t args_len)
|
||||||
|
{
|
||||||
|
_labeling_policy.filter_session_args(service, args, args_len);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool announce_service(const char *service_name,
|
||||||
|
Genode::Root_capability root,
|
||||||
|
Genode::Allocator *alloc,
|
||||||
|
Genode::Server * /*server*/)
|
||||||
|
{
|
||||||
|
if (_child_services->find(service_name)) {
|
||||||
|
PWRN("%s: service %s is already registered",
|
||||||
|
name(), service_name);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* XXX remove potential race between checking for and inserting service */
|
||||||
|
|
||||||
|
_child_services->insert(new (alloc)
|
||||||
|
Genode::Child_service(service_name, root, _server));
|
||||||
|
Genode::printf("%s registered service %s\n", name(), service_name);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void unregister_services()
|
||||||
|
{
|
||||||
|
Genode::Service *rs;
|
||||||
|
while ((rs = _child_services->find_by_server(_server)))
|
||||||
|
_child_services->remove(rs);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -192,6 +247,7 @@ class Launchpad
|
|||||||
*/
|
*/
|
||||||
void process_config();
|
void process_config();
|
||||||
|
|
||||||
|
|
||||||
/*************************
|
/*************************
|
||||||
** Configuring the GUI **
|
** Configuring the GUI **
|
||||||
*************************/
|
*************************/
|
||||||
@ -210,8 +266,6 @@ class Launchpad
|
|||||||
virtual void remove_child(const char *name,
|
virtual void remove_child(const char *name,
|
||||||
Genode::Allocator *alloc) { }
|
Genode::Allocator *alloc) { }
|
||||||
|
|
||||||
// virtual void child_quota(const char *name, unsigned long quota) { }
|
|
||||||
|
|
||||||
Launchpad_child *start_child(const char *prg_name, unsigned long quota,
|
Launchpad_child *start_child(const char *prg_name, unsigned long quota,
|
||||||
Genode::Dataspace_capability config_ds);
|
Genode::Dataspace_capability config_ds);
|
||||||
|
|
||||||
|
@ -311,119 +311,6 @@ class Init::Child_policy_redirect_rom_file
|
|||||||
|
|
||||||
Genode::snprintf(buf, sizeof(buf), "\"%s%s\"", label, _to);
|
Genode::snprintf(buf, sizeof(buf), "\"%s%s\"", label, _to);
|
||||||
Genode::Arg_string::set_arg(args, args_len, "label", buf);
|
Genode::Arg_string::set_arg(args, args_len, "label", buf);
|
||||||
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class Init::Traditional_child_policy : public Genode::Child_policy,
|
|
||||||
public Genode::Client
|
|
||||||
{
|
|
||||||
protected:
|
|
||||||
|
|
||||||
enum { NAME_LEN = 64 };
|
|
||||||
char _name[NAME_LEN];
|
|
||||||
|
|
||||||
char const *_root;
|
|
||||||
|
|
||||||
Genode::Server *_server;
|
|
||||||
Genode::Service_registry *_parent_services;
|
|
||||||
Genode::Service_registry *_child_services;
|
|
||||||
Genode::Dataspace_capability _config_ds;
|
|
||||||
Genode::Rpc_entrypoint *_parent_entrypoint;
|
|
||||||
Child_policy_enforce_labeling _labeling_policy;
|
|
||||||
Child_policy_handle_cpu_priorities _priority_policy;
|
|
||||||
Child_policy_provide_rom_file _config_policy;
|
|
||||||
Child_policy_provide_rom_file _binary_policy;
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
*/
|
|
||||||
Traditional_child_policy(const char *name,
|
|
||||||
Genode::Server *server,
|
|
||||||
Genode::Service_registry *parent_services,
|
|
||||||
Genode::Service_registry *child_services,
|
|
||||||
Genode::Dataspace_capability config_ds,
|
|
||||||
Genode::Dataspace_capability binary_ds,
|
|
||||||
long prio_levels_log2,
|
|
||||||
long priority,
|
|
||||||
char const *root,
|
|
||||||
Genode::Rpc_entrypoint *parent_entrypoint)
|
|
||||||
:
|
|
||||||
_root(root),
|
|
||||||
_server(server),
|
|
||||||
_parent_services(parent_services),
|
|
||||||
_child_services(child_services),
|
|
||||||
_config_ds(config_ds),
|
|
||||||
_parent_entrypoint(parent_entrypoint),
|
|
||||||
_labeling_policy(_name),
|
|
||||||
_priority_policy(prio_levels_log2, priority),
|
|
||||||
_config_policy("config", config_ds, _parent_entrypoint),
|
|
||||||
_binary_policy("binary", binary_ds, _parent_entrypoint)
|
|
||||||
{
|
|
||||||
Genode::strncpy(_name, name, sizeof(_name));
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *name() const { return _name; }
|
|
||||||
|
|
||||||
Genode::Service *resolve_session_request(const char *service_name,
|
|
||||||
const char *args)
|
|
||||||
{
|
|
||||||
Genode::Service *service;
|
|
||||||
|
|
||||||
/* check for config file request */
|
|
||||||
if ((service = _config_policy.resolve_session_request(service_name, args)))
|
|
||||||
return service;
|
|
||||||
|
|
||||||
/* check for binary file request */
|
|
||||||
if ((service = _binary_policy.resolve_session_request(service_name, args)))
|
|
||||||
return service;
|
|
||||||
|
|
||||||
/* check for services provided by the parent */
|
|
||||||
if ((service = _parent_services->find(service_name)))
|
|
||||||
return service;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If the service is provided by one of our children use it,
|
|
||||||
* or wait for the service to become available.
|
|
||||||
*/
|
|
||||||
return _child_services->wait_for_service(service_name, this,
|
|
||||||
name());
|
|
||||||
}
|
|
||||||
|
|
||||||
void filter_session_args(const char *service, char *args,
|
|
||||||
Genode::size_t args_len)
|
|
||||||
{
|
|
||||||
_labeling_policy.filter_session_args(service, args, args_len);
|
|
||||||
_priority_policy.filter_session_args(service, args, args_len);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool announce_service(const char *service_name,
|
|
||||||
Genode::Root_capability root,
|
|
||||||
Genode::Allocator *alloc,
|
|
||||||
Genode::Server * /*server*/)
|
|
||||||
{
|
|
||||||
if (_child_services->find(service_name)) {
|
|
||||||
PWRN("%s: service %s is already registered",
|
|
||||||
name(), service_name);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* XXX remove potential race between checking for and inserting service */
|
|
||||||
|
|
||||||
_child_services->insert(new (alloc)
|
|
||||||
Genode::Child_service(service_name, root, _server));
|
|
||||||
Genode::printf("%s registered service %s\n", name(), service_name);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void unregister_services()
|
|
||||||
{
|
|
||||||
Genode::Service *rs;
|
|
||||||
while ((rs = _child_services->find_by_server(_server)))
|
|
||||||
_child_services->remove(rs);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user