Skip to main content

Module server

Module server 

Source
Expand description

Control socket for the Selkies V4L2 interposer.

Each application open() of the virtual device becomes one client connection. The server sends the ring configuration once, with the ring memfd attached as SCM_RIGHTS ancillary data, then only ever writes one-byte doorbells — one per published frame — so the interposer can block in poll()/VIDIOC_DQBUF on plain socket readability. Frame bytes never cross the socket. The interposer answers the handshake with a single byte; until that arrives a client gets no doorbells, and a closed connection is retired the moment its read end reports hangup.

The accept/hangup loop runs on its own thread, woken through an eventfd for shutdown, so a process that opens the device while no frames flow is still served immediately.

Structs§

Client 🔒
Server
Shared 🔒

Functions§

accept_clients 🔒
peer_is_session_user 🔒
Whether a socket’s peer runs as this process’s user or as root, who passes the socket’s mode anyway: one that connected before restrict_to_owner is refused here.
restrict_to_owner 🔒
Make a socket this process bound connectable by its user alone, whatever the umask.
send_config_with_fd 🔒
Send the configuration struct with the ring memfd attached as SCM_RIGHTS.
serve 🔒