From dda168fc102843484a06b1b11e230f8fef8d4dc0 Mon Sep 17 00:00:00 2001 From: Stefan Kalkowski Date: Fri, 2 Sep 2022 13:35:13 +0200 Subject: [PATCH] platform API: simplify _wait_for_device Fix genodelabs/genode#4615 --- .../os/include/platform_session/connection.h | 28 ++++++++----------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/repos/os/include/platform_session/connection.h b/repos/os/include/platform_session/connection.h index 350c8c7a1d..fbfa62a024 100644 --- a/repos/os/include/platform_session/connection.h +++ b/repos/os/include/platform_session/connection.h @@ -39,10 +39,11 @@ class Platform::Connection : public Genode::Connection, friend class Device; friend class Dma_buffer; - Env &_env; - Rom_session_client _rom {devices_rom()}; - Constructible _ds {}; - Constructible> _handler {}; + Env & _env; + Rom_session_client _rom { devices_rom() }; + Constructible _ds {}; + Io_signal_handler _handler { _env.ep(), *this, + &Connection::_handle_io }; void _try_attach() { @@ -60,19 +61,8 @@ class Platform::Connection : public Genode::Connection, for (;;) { /* repeatedly check for availability of device */ Capability cap = fn(); - if (cap.valid()) { - if (_handler.constructed()) { - sigh(Signal_context_capability()); - _handler.destruct(); - } + if (cap.valid()) return cap; - } - - if (!_handler.constructed()) { - _handler.construct(_env.ep(), *this, - &Connection::_handle_io); - sigh(*_handler); - } _env.ep().wait_and_dispatch_one_io_signal(); } @@ -89,6 +79,12 @@ class Platform::Connection : public Genode::Connection, _env(env) { _try_attach(); + + /* + * Initially register dummy handler, to be able to receive signals + * if _wait_for_device probes for a valid devices rom + */ + sigh(_handler); } void update()