VLC 4.0.0-dev
Loading...
Searching...
No Matches
interrupt.c File Reference
Include dependency graph for interrupt.c:

Functions

void vlc_interrupt_init (vlc_interrupt_t *ctx)
 Initializes an interruption context.
 
vlc_interrupt_tvlc_interrupt_create (void)
 Creates an interruption context.
 
void vlc_interrupt_deinit (vlc_interrupt_t *ctx)
 Deinitializes an interruption context.
 
void vlc_interrupt_destroy (vlc_interrupt_t *ctx)
 Destroys an interrupt context.
 
void vlc_interrupt_raise (vlc_interrupt_t *ctx)
 Raises an interruption through a specified context.
 
vlc_interrupt_tvlc_interrupt_set (vlc_interrupt_t *newctx)
 Sets the interruption context for the calling thread.
 
static void vlc_interrupt_prepare (vlc_interrupt_t *ctx, void(*cb)(void *), void *data)
 Prepares to enter interruptible wait.
 
static int vlc_interrupt_finish (vlc_interrupt_t *ctx)
 Cleans up after an interruptible wait: waits for any pending invocations of the callback previously registered with vlc_interrupt_prepare(), and rechecks for any pending interruption.
 
void vlc_interrupt_register (void(*cb)(void *), void *opaque)
 Registers a custom interrupt handler.
 
int vlc_interrupt_unregister (void)
 
static void vlc_interrupt_cleanup (void *opaque)
 
void vlc_interrupt_kill (vlc_interrupt_t *ctx)
 Marks the interruption context as "killed".
 
bool vlc_killed (void)
 Checks if the interruption context was "killed".
 
static void vlc_interrupt_sem (void *opaque)
 
int vlc_sem_wait_i11e (vlc_sem_t *sem)
 Interruptible variant of vlc_sem_wait().
 
static void vlc_mwait_i11e_wake (void *opaque)
 
static void vlc_mwait_i11e_cleanup (void *opaque)
 
int vlc_mwait_i11e (vlc_tick_t deadline)
 Interruptible variant of vlc_tick_wait().
 
static void vlc_interrupt_forward_wake (void *opaque)
 
void vlc_interrupt_forward_start (vlc_interrupt_t *to, void *data[2])
 Enables forwarding of interruption.
 
int vlc_interrupt_forward_stop (void *const data[2])
 Undoes vlc_interrupt_forward_start().
 
static void vlc_poll_i11e_wake (void *opaque)
 
static void vlc_poll_i11e_cleanup (void *opaque)
 
static int vlc_poll_i11e_inner (struct pollfd *restrict fds, unsigned nfds, int timeout, vlc_interrupt_t *ctx, struct pollfd *restrict ufd)
 
int vlc_poll_i11e (struct pollfd *fds, unsigned nfds, int timeout)
 Interruptible variant of poll().
 
static int vlc_poll_file (int fd, unsigned int mask)
 
static int vlc_poll_sock (int sock, unsigned int mask)
 
ssize_t vlc_readv_i11e (int fd, struct iovec *iov, int count)
 Wrapper for readv() that returns the EINTR error upon VLC I/O interruption.
 
ssize_t vlc_writev_i11e (int fd, const struct iovec *iov, int count)
 Wrapper for writev() that returns the EINTR error upon VLC I/O interruption.
 
ssize_t vlc_read_i11e (int fd, void *buf, size_t count)
 Wrapper for read() that returns the EINTR error upon VLC I/O interruption.
 
ssize_t vlc_write_i11e (int fd, const void *buf, size_t count)
 Wrapper for write() that returns the EINTR error upon VLC I/O interruption.
 
ssize_t vlc_recvmsg_i11e (int fd, struct msghdr *msg, int flags)
 
ssize_t vlc_recvfrom_i11e (int fd, void *buf, size_t len, int flags, struct sockaddr *addr, socklen_t *addrlen)
 
ssize_t vlc_sendmsg_i11e (int fd, const struct msghdr *msg, int flags)
 
ssize_t vlc_sendto_i11e (int fd, const void *buf, size_t len, int flags, const struct sockaddr *addr, socklen_t addrlen)
 
int vlc_accept_i11e (int fd, struct sockaddr *addr, socklen_t *addrlen, bool nonblock)
 

Variables

static thread_local vlc_interrupt_tvlc_interrupt_var
 

Function Documentation

◆ vlc_interrupt_cleanup()

static void vlc_interrupt_cleanup ( void *  opaque)
static

References vlc_interrupt_finish().

Referenced by vlc_sem_wait_i11e().

◆ vlc_interrupt_deinit()

void vlc_interrupt_deinit ( vlc_interrupt_t ctx)

Deinitializes an interruption context.

The context shall no longer be used by any thread.

References vlc_interrupt::callback.

Referenced by input_Close(), TaskDelete(), and vlc_interrupt_destroy().

◆ vlc_interrupt_finish()

static int vlc_interrupt_finish ( vlc_interrupt_t ctx)
static

Cleans up after an interruptible wait: waits for any pending invocations of the callback previously registered with vlc_interrupt_prepare(), and rechecks for any pending interruption.

Warning
As this function waits for ongoing callback invocation to complete, the caller must not hold any resource necessary for the callback to run. Otherwise a deadlock may occur.
Returns
EINTR if an interruption occurred, zero otherwise

References vlc_interrupt::callback, vlc_interrupt::interrupted, vlc_interrupt::lock, vlc_interrupt_var, vlc_mutex_lock(), and vlc_mutex_unlock().

Referenced by vlc_interrupt_cleanup(), vlc_interrupt_forward_stop(), vlc_interrupt_unregister(), vlc_mwait_i11e(), vlc_mwait_i11e_cleanup(), vlc_poll_i11e_cleanup(), vlc_poll_i11e_inner(), and vlc_sem_wait_i11e().

◆ vlc_interrupt_forward_wake()

static void vlc_interrupt_forward_wake ( void *  opaque)
static

◆ vlc_interrupt_prepare()

static void vlc_interrupt_prepare ( vlc_interrupt_t ctx,
void(*)(void *)  cb,
void *  data 
)
static

Prepares to enter interruptible wait.

Parameters
ctxan unused interruption context to prepare
cbcallback to interrupt the wait (i.e. wake up the thread)
dataopaque data pointer for the callback
Note
Any successful call must be paired with a call to vlc_interrupt_finish().

References vlc_interrupt::callback, vlc_interrupt::data, vlc_interrupt::interrupted, vlc_interrupt::lock, unlikely, vlc_interrupt_var, vlc_mutex_lock(), and vlc_mutex_unlock().

Referenced by vlc_interrupt_forward_start(), vlc_interrupt_register(), vlc_mwait_i11e(), vlc_poll_i11e_inner(), and vlc_sem_wait_i11e().

◆ vlc_interrupt_sem()

static void vlc_interrupt_sem ( void *  opaque)
static

References vlc_sem_post().

Referenced by vlc_sem_wait_i11e().

◆ vlc_mwait_i11e_cleanup()

static void vlc_mwait_i11e_cleanup ( void *  opaque)
static

◆ vlc_mwait_i11e_wake()

static void vlc_mwait_i11e_wake ( void *  opaque)
static

References vlc_cond_signal().

Referenced by vlc_mwait_i11e().

◆ vlc_poll_file()

static int vlc_poll_file ( int  fd,
unsigned int  mask 
)
static

◆ vlc_poll_i11e_cleanup()

static void vlc_poll_i11e_cleanup ( void *  opaque)
static

◆ vlc_poll_i11e_inner()

static int vlc_poll_i11e_inner ( struct pollfd *restrict  fds,
unsigned  nfds,
int  timeout,
vlc_interrupt_t ctx,
struct pollfd *restrict  ufd 
)
static

◆ vlc_poll_i11e_wake()

static void vlc_poll_i11e_wake ( void *  opaque)
static

◆ vlc_poll_sock()

static int vlc_poll_sock ( int  sock,
unsigned int  mask 
)
static