mirror of
https://github.com/genodelabs/genode.git
synced 2025-06-16 14:18:27 +00:00
Create entrypoint sockets in core only
This patch alleviates the need for any non-core process to create Unix domain sockets locally. All sockets used for RPC communication are created by core and subsequently passed to the other processes via RPC or the parent interface. The immediate benefit is that no process other than core needs to access the 'rpath' directory in order to communicate. However, access to 'rpath' is still needed for accessing dataspaces. Core creates one socket pair per thread on demand on the first call of the 'Linux_cpu_session::server_sd()' or 'Linux_cpu_session::client_sd()' functions. 'Linux_cpu_session' is a Linux-specific extension to the CPU session interface. In addition to the socket accessors, the extension provides a mechanism to register the PID/TID of a thread. Those information were formerly propagated into core along with the thread name as argument to 'create_thread()'. Because core creates socket pairs for entrypoints, it needs to know all threads that are potential entrypoints. For lx_hybrid programs, we hadn't had propagated any thread information into core, yet. Hence, this patch also contains the code for registering threads of hybrid applications at core.
This commit is contained in:
@ -31,13 +31,10 @@
|
||||
#include <base/ipc.h>
|
||||
#include <base/thread.h>
|
||||
#include <base/blocking.h>
|
||||
#include <base/env.h>
|
||||
#include <linux_cpu_session/linux_cpu_session.h>
|
||||
|
||||
/* Linux includes */
|
||||
#include <sys/socket.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/un.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <linux_socket.h>
|
||||
#include <linux_syscalls.h>
|
||||
|
||||
@ -219,6 +216,20 @@ void Ipc_server::_reply_wait()
|
||||
}
|
||||
|
||||
|
||||
namespace Genode {
|
||||
|
||||
/*
|
||||
* Helper for obtaining a bound and connected socket pair
|
||||
*
|
||||
* For core, the implementation is just a wrapper around
|
||||
* 'lx_server_socket_pair()'. For all other processes, the implementation
|
||||
* requests the socket pair from the Env::CPU session interface using a
|
||||
* Linux-specific interface extension.
|
||||
*/
|
||||
Native_connection_state server_socket_pair();
|
||||
}
|
||||
|
||||
|
||||
Ipc_server::Ipc_server(Msgbuf_base *snd_msg, Msgbuf_base *rcv_msg)
|
||||
:
|
||||
Ipc_istream(rcv_msg),
|
||||
@ -238,10 +249,10 @@ Ipc_server::Ipc_server(Msgbuf_base *snd_msg, Msgbuf_base *rcv_msg)
|
||||
throw Ipc_server_multiple_instance();
|
||||
}
|
||||
|
||||
_rcv_cs = lx_server_socket_pair(Thread_base::myself());
|
||||
|
||||
if (thread)
|
||||
if (thread) {
|
||||
_rcv_cs = server_socket_pair();
|
||||
thread->tid().is_ipc_server = true;
|
||||
}
|
||||
|
||||
/* override capability initialization performed by 'Ipc_istream' */
|
||||
*static_cast<Native_capability *>(this) =
|
||||
|
Reference in New Issue
Block a user