Monado OpenXR Runtime
Loading...
Searching...
No Matches
ipc_server_thread_shutdown.h File Reference

IPC client thread shutdown and blocking I/O cancellation. More...

#include "xrt/xrt_config_os.h"
#include <stdbool.h>
Include dependency graph for ipc_server_thread_shutdown.h:

Go to the source code of this file.

Functions

void ipc_server_client_thread_set_running (struct ipc_server *s, struct ipc_thread *it)
 Do not revive a starting thread that shutdown has already stopped.
 
bool ipc_server_client_thread_is_running (struct ipc_server *s, struct ipc_thread *it)
 Read the loop state under the same lock used to stop or start it.
 
void ipc_server_stop_and_join_client_threads (struct ipc_server *s)
 Stop all client loops, wake blocking I/O, then join each thread once.
 

Detailed Description

IPC client thread shutdown and blocking I/O cancellation.

Author
Nick Kennedy code@.nosp@m.nick.nosp@m.-kenn.nosp@m.edy..nosp@m.com

Function Documentation

◆ ipc_server_client_thread_is_running()

bool ipc_server_client_thread_is_running ( struct ipc_server *  s,
struct ipc_thread *  it 
)

Read the loop state under the same lock used to stop or start it.

◆ ipc_server_client_thread_set_running()

void ipc_server_client_thread_set_running ( struct ipc_server *  s,
struct ipc_thread *  it 
)

Do not revive a starting thread that shutdown has already stopped.

◆ ipc_server_stop_and_join_client_threads()

void ipc_server_stop_and_join_client_threads ( struct ipc_server *  s)

Stop all client loops, wake blocking I/O, then join each thread once.

Called by the server main thread after it stops accepting connections. Joining finishes client cleanup before the caller destroys server resources or restarts the main loop. Calls must be serialized on that main thread. Safe to repeat: joined slots are READY and no longer own a thread.

Stop all client loops, wake blocking I/O, then join each thread once.

Client threads may still be inside common_shutdown(), which destroys each client's compositor and dereferences s->xsysd / s->xso. Joining them before teardown_all() destroys those resources avoids a race where a client thread locks a mutex that teardown has already freed (observed as an om->initialized assertion in multi_compositor_destroy).

Stop their loops before joining: the epoll based client loop notices STOPPING on its next timeout, while the Windows one is woken by ipc_server_cancel_all_client_io.

Called from shutdown_clients() before the main loop returns, and again from teardown_all() as a fallback.