Monado OpenXR Runtime
ipc_server_mainloop Struct Reference

Platform-specific mainloop object for the IPC server. More...

#include </builds/monado/monado/src/xrt/ipc/server/ipc_server.h>

Collaboration diagram for ipc_server_mainloop:

Public Member Functions

void ipc_server_mainloop_deinit (struct ipc_server_mainloop *ml)
 De-initialize the mainloop object. More...
 
int ipc_server_mainloop_init (struct ipc_server_mainloop *ml)
 Initialize the mainloop object. More...
 
void ipc_server_mainloop_poll (struct ipc_server *vs, struct ipc_server_mainloop *ml)
 Poll the mainloop. More...
 
int ipc_server_mainloop_add_fd (struct ipc_server *vs, struct ipc_server_mainloop *ml, int newfd)
 Pass an fd for a new client to the mainloop. More...
 

Data Fields

int epoll_fd
 For waiting on various events in the main thread. More...
 
Android Mainloop Members
int pipe_read
 File descriptor for the read end of our pipe for submitting new clients. More...
 
int pipe_write
 File descriptor for the write end of our pipe for submitting new clients. More...
 
pthread_mutex_t client_push_mutex
 Mutex for being able to register oneself as a new client. More...
 
int last_accepted_fd
 The last client fd we accepted, to acknowledge client acceptance. More...
 
pthread_cond_t accept_cond
 Condition variable for accepting clients. More...
 
pthread_mutex_t accept_mutex
 Mutex for accepting clients. More...
 
Desktop Linux Mainloop Members
int listen_socket
 Socket that we accept connections on. More...
 
bool launched_by_socket
 Were we launched by socket activation, instead of explicitly? More...
 
char * socket_filename
 The socket filename we bound to, if any. More...
 
Desktop Windows Mainloop Members
HANDLE pipe_handle
 Named Pipe that we accept connections on. More...
 
char * pipe_name
 Name of the Pipe that we accept connections on. More...
 

Detailed Description

Platform-specific mainloop object for the IPC server.

Contents are essentially implementation details, but are listed in full here so they may be included by value in the main ipc_server struct.

See also
ipc_design

Member Function Documentation

◆ ipc_server_mainloop_add_fd()

int ipc_server_mainloop_add_fd ( struct ipc_server vs,
struct ipc_server_mainloop ml,
int  newfd 
)

Pass an fd for a new client to the mainloop.

See also
ipc_design

References accept_mutex, client_push_mutex, last_accepted_fd, pipe_write, and U_LOG_E.

◆ ipc_server_mainloop_deinit()

void ipc_server_mainloop_deinit ( struct ipc_server_mainloop ml)

De-initialize the mainloop object.

References accept_cond, accept_mutex, last_accepted_fd, and pipe_read.

◆ ipc_server_mainloop_init()

int ipc_server_mainloop_init ( struct ipc_server_mainloop ml)

Initialize the mainloop object.

Returns
<0 on error.

◆ ipc_server_mainloop_poll()

void ipc_server_mainloop_poll ( struct ipc_server vs,
struct ipc_server_mainloop ml 
)

Poll the mainloop.

Any errors are signalled by calling ipc_server_handle_failure()

References epoll_fd.

Field Documentation

◆ accept_cond

pthread_cond_t ipc_server_mainloop::accept_cond

Condition variable for accepting clients.

Signalled when last_accepted_fd is updated.

Associated with accept_mutex

Referenced by ipc_server_mainloop_deinit().

◆ accept_mutex

pthread_mutex_t ipc_server_mainloop::accept_mutex

Mutex for accepting clients.

Locked by both clients and server: that is, by threads in ipc_server_mainloop_add_fd() and in the server/compositor thread in an implementation function called from ipc_server_mainloop_poll().

Exists to operate in conjunction with accept_cond - it exists to make sure that the client can be woken when the server accepts it.

Referenced by ipc_server_mainloop_add_fd(), and ipc_server_mainloop_deinit().

◆ client_push_mutex

pthread_mutex_t ipc_server_mainloop::client_push_mutex

Mutex for being able to register oneself as a new client.

Locked only by threads in ipc_server_mainloop_add_fd().

This must be locked first, and kept locked the entire time a client is attempting to register and wait for confirmation. It ensures no acknowledgements of acceptance are lost and moves the overhead of ensuring this to the client thread.

Referenced by ipc_server_mainloop_add_fd().

◆ epoll_fd

int ipc_server_mainloop::epoll_fd

For waiting on various events in the main thread.

Referenced by ipc_server_mainloop_poll().

◆ last_accepted_fd

int ipc_server_mainloop::last_accepted_fd

The last client fd we accepted, to acknowledge client acceptance.

Also used as a sentinel during shutdown.

Must hold accept_mutex while writing.

Referenced by ipc_server_mainloop_add_fd(), and ipc_server_mainloop_deinit().

◆ launched_by_socket

bool ipc_server_mainloop::launched_by_socket

Were we launched by socket activation, instead of explicitly?

◆ listen_socket

int ipc_server_mainloop::listen_socket

Socket that we accept connections on.

◆ pipe_handle

HANDLE ipc_server_mainloop::pipe_handle

Named Pipe that we accept connections on.

◆ pipe_name

char* ipc_server_mainloop::pipe_name

Name of the Pipe that we accept connections on.

◆ pipe_read

int ipc_server_mainloop::pipe_read

File descriptor for the read end of our pipe for submitting new clients.

Referenced by ipc_server_mainloop_deinit().

◆ pipe_write

int ipc_server_mainloop::pipe_write

File descriptor for the write end of our pipe for submitting new clients.

Must hold client_push_mutex while writing.

Referenced by ipc_server_mainloop_add_fd().

◆ socket_filename

char* ipc_server_mainloop::socket_filename

The socket filename we bound to, if any.


The documentation for this struct was generated from the following files: