mirror of
https://github.com/genodelabs/genode.git
synced 2025-01-31 16:35:28 +00:00
d3m: Fix deadlock of usb_drv
This deadlock was introduced by the change of USB driver to the server API. Fixes #1052
This commit is contained in:
parent
6f9e15aff8
commit
9947c3d33b
@ -129,6 +129,11 @@ struct Usb_policy : public Genode::Slave_policy
|
||||
Block::Driver_registry &_block_driver_registry;
|
||||
Block::Driver _block_driver;
|
||||
|
||||
Genode::Root_capability _input_root;
|
||||
Genode::Root_capability _block_root;
|
||||
Genode::Lock _input_root_lock;
|
||||
Genode::Lock _block_root_lock;
|
||||
|
||||
protected:
|
||||
|
||||
const char **_permitted_services() const
|
||||
@ -150,7 +155,9 @@ struct Usb_policy : public Genode::Slave_policy
|
||||
:
|
||||
Genode::Slave_policy("usb_drv", entrypoint, ram),
|
||||
_input_source_registry(input_source_registry),
|
||||
_block_driver_registry(block_driver_registry)
|
||||
_block_driver_registry(block_driver_registry),
|
||||
_input_root_lock(Genode::Lock::LOCKED),
|
||||
_block_root_lock(Genode::Lock::LOCKED)
|
||||
{
|
||||
configure(config);
|
||||
}
|
||||
@ -160,20 +167,35 @@ struct Usb_policy : public Genode::Slave_policy
|
||||
Genode::Allocator *alloc,
|
||||
Genode::Server *server)
|
||||
{
|
||||
PINF("announce_service %s", service_name);
|
||||
if (Genode::strcmp(service_name, "Input") == 0) {
|
||||
_input_source_registry_entry.connect(root);
|
||||
_input_source_registry.add_source(&_input_source_registry_entry);
|
||||
_input_root = root;
|
||||
_input_root_lock.unlock();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Genode::strcmp(service_name, "Block") == 0) {
|
||||
_block_driver.init("usb_drv", root);
|
||||
_block_driver_registry.add_driver(&_block_driver);
|
||||
_block_root = root;
|
||||
_block_root_lock.unlock();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void connect_input()
|
||||
{
|
||||
_input_root_lock.lock();
|
||||
_input_source_registry_entry.connect(_input_root);
|
||||
_input_source_registry.add_source(&_input_source_registry_entry);
|
||||
}
|
||||
|
||||
void connect_block()
|
||||
{
|
||||
_block_root_lock.lock();
|
||||
_block_driver.init("usb_drv", _block_root);
|
||||
_block_driver_registry.add_driver(&_block_driver);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -287,6 +309,9 @@ int main(int argc, char **argv)
|
||||
env()->parent()->announce(ep.manage(&block_root));
|
||||
}
|
||||
|
||||
usb_policy.connect_input();
|
||||
usb_policy.connect_block();
|
||||
|
||||
Genode::sleep_forever();
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user