libc blocking functions/with_libc inside thread

Christian Helmuth christian.helmuth at ...1...
Fri Jun 23 14:40:12 CEST 2017


Hello Boris,

On Fri, Jun 23, 2017 at 02:24:01PM +0200, Boris Mulder wrote:
> However, sockets in lxip require the use of the with_libc() function.
> When I put this around the openvpn_main() call it gives me the error:
> 
> Error: void Libc::Kernel::run(Libc::Application_code&) called from
> non-kernel context
> 
> The catch here is that I'm calling all this from inside the code of a
> Genode::Thread which executes the main function of openvpn. It seems
> that I cannot use with_libc inside another thread than the entrypoint
> thread.

We also identified that exposing the with_libc() in the Libc API was
the wrong direction. Therefore, we'll work on moving this aspect back
into the libc internals in the future. You're right with regard that
with_libc is not permitted/needed for other threads/pthreads in libc
applications. Blocking situations are handled differently for threads
beside the main entrypoint. But, the main entrypoint thread needs to
finish I/O operations by handling the I/O signals of Genode sessions
used by the component.

> calling with_libc inside Component::construct() does not work for the
> new thread. It will fail when calling socket().
> 
> Is there any way of using sockets correctly inside another thread?

How does socket() fail if you do not wrap the call with with_libc()?
I'd expect the thread to open a socket_fs file and maybe block for the
I/O operation to complete. Also, is there any reason to use a
Genode::Thread which uses POSIX interfaces only (beside the admittedly
more concise syntax compared to pthread_create())?

Greets
-- 
Christian Helmuth
Genode Labs

https://www.genode-labs.com/ · https://genode.org/
https://twitter.com/GenodeLabs · /ˈdʒiː.nəʊd/

Genode Labs GmbH · Amtsgericht Dresden · HRB 28424 · Sitz Dresden
Geschäftsführer: Dr.-Ing. Norman Feske, Christian Helmuth




More information about the users mailing list