VLC  3.0.0-git
Functions
Interruptible sleep functions
Collaboration diagram for Interruptible sleep functions:

Functions

int vlc_sem_wait_i11e (vlc_sem_t *)
 Interruptible variant of vlc_sem_wait(). More...
 
int vlc_mwait_i11e (mtime_t)
 Interruptible variant of mwait(). More...
 
static int vlc_msleep_i11e (mtime_t delay)
 Interruptible variant of msleep(). More...
 
int vlc_poll_i11e (struct pollfd *, unsigned, int)
 Interruptible variant of poll(). More...
 
ssize_t vlc_readv_i11e (int fd, struct iovec *, int)
 Wrapper for readv() that returns the EINTR error upon VLC I/O interruption. More...
 
ssize_t vlc_writev_i11e (int fd, const struct iovec *, int)
 Wrapper for writev() that returns the EINTR error upon VLC I/O interruption. More...
 
ssize_t vlc_read_i11e (int fd, void *, size_t)
 Wrapper for read() that returns the EINTR error upon VLC I/O interruption. More...
 
ssize_t vlc_write_i11e (int fd, const void *, size_t)
 Wrapper for write() that returns the EINTR error upon VLC I/O interruption. More...
 
ssize_t vlc_recvmsg_i11e (int fd, struct msghdr *, int flags)
 
ssize_t vlc_sendmsg_i11e (int fd, const struct msghdr *, int flags)
 
ssize_t vlc_recvfrom_i11e (int fd, void *, size_t, int flags, struct sockaddr *, socklen_t *)
 
ssize_t vlc_sendto_i11e (int fd, const void *, size_t, int flags, const struct sockaddr *, socklen_t)
 
static ssize_t vlc_recv_i11e (int fd, void *buf, size_t len, int flags)
 
static ssize_t vlc_send_i11e (int fd, const void *buf, size_t len, int flags)
 
int vlc_accept_i11e (int fd, struct sockaddr *, socklen_t *, bool)
 
void vlc_interrupt_register (void(*cb)(void *), void *opaque)
 Registers a custom interrupt handler. More...
 
int vlc_interrupt_unregister (void)
 

Detailed Description

Function Documentation

◆ vlc_accept_i11e()

int vlc_accept_i11e ( int  fd,
struct sockaddr *  ,
socklen_t *  ,
bool   
)

◆ vlc_interrupt_register()

void vlc_interrupt_register ( void(*)(void *)  cb,
void *  opaque 
)

Registers a custom interrupt handler.

Registers a custom callback as interrupt handler for the calling thread. The callback must be unregistered with vlc_interrupt_unregister() before thread termination and before any further callback registration.

If the calling thread has no interruption context, this function has no effects.

References vlc_interrupt_prepare(), and vlc_interrupt_var.

Referenced by dialog_wait(), vlc_h2_stream_lock(), and vlc_send_i11e().

◆ vlc_interrupt_unregister()

int vlc_interrupt_unregister ( void  )

◆ vlc_msleep_i11e()

static int vlc_msleep_i11e ( mtime_t  delay)
inlinestatic

Interruptible variant of msleep().

Waits for a specified timeout duration or, if the calling thread has an interruption context, an interruption.

Parameters
delaytimeout value (in microseconds)
Returns
EINTR if an interruption occurred, otherwise 0 once the timeout expired.

References mdate(), VLC_API, vlc_mwait_i11e(), vlc_poll_i11e(), vlc_read_i11e(), vlc_readv_i11e(), vlc_recvfrom_i11e(), vlc_recvmsg_i11e(), vlc_sendmsg_i11e(), vlc_sendto_i11e(), vlc_write_i11e(), and vlc_writev_i11e().

◆ vlc_mwait_i11e()

int vlc_mwait_i11e ( mtime_t  )

Interruptible variant of mwait().

Waits for a specified timestamp or, if the calling thread has an interruption context, an interruption.

Returns
EINTR if an interruption occurred, otherwise 0 once the timestamp is reached.

References vlc_interrupt::interrupted, vlc_interrupt::lock, mwait, vlc_cleanup_pop, vlc_cleanup_push, vlc_cond_destroy(), vlc_cond_init(), vlc_cond_timedwait(), vlc_interrupt_finish(), vlc_interrupt_prepare(), vlc_interrupt_var, vlc_mutex_lock(), vlc_mutex_unlock(), vlc_mwait_i11e_cleanup(), and vlc_mwait_i11e_wake().

Referenced by vlc_msleep_i11e().

◆ vlc_poll_i11e()

int vlc_poll_i11e ( struct pollfd ,
unsigned  ,
int   
)

Interruptible variant of poll().

Waits for file descriptors I/O events, a timeout, a signal or a VLC I/O interruption. Except for VLC I/O interruptions, this function behaves just like the standard poll().

Note
This function is always a cancellation point (as poll()).
See also
poll() manual page
Parameters
fdstable of events to wait for
nfdsnumber of entries in the table
timeouttime to wait in milliseconds or -1 for infinite
Returns
A strictly positive result represent the number of pending events. 0 is returned if the time-out is reached without events. -1 is returned if a VLC I/O interrupt occurs (and errno is set to EINTR) or if an error occurs.

References likely, poll(), unlikely, vlc_cleanup_pop, vlc_cleanup_push, vlc_interrupt_var, and vlc_poll_i11e_inner().

Referenced by net_Connect(), vlc_accept_i11e(), vlc_msleep_i11e(), vlc_readv_i11e(), vlc_recvmsg_i11e(), vlc_sendmsg_i11e(), vlc_tls_Read(), vlc_tls_WaitConnect(), vlc_tls_Write(), and vlc_writev_i11e().

◆ vlc_read_i11e()

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.

Warning
This function ignores the non-blocking file flag.

References vlc_readv_i11e().

Referenced by vlc_accept_i11e(), and vlc_msleep_i11e().

◆ vlc_readv_i11e()

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.

Warning
This function ignores the non-blocking file flag.

References pollfd::events, pollfd::fd, POLLIN, and vlc_poll_i11e().

Referenced by vlc_accept_i11e(), vlc_msleep_i11e(), and vlc_read_i11e().

◆ vlc_recv_i11e()

static ssize_t vlc_recv_i11e ( int  fd,
void *  buf,
size_t  len,
int  flags 
)
inlinestatic

References vlc_recvfrom_i11e().

Referenced by net_Gets(), and net_Read().

◆ vlc_recvfrom_i11e()

ssize_t vlc_recvfrom_i11e ( int  fd,
void *  ,
size_t  ,
int  flags,
struct sockaddr *  ,
socklen_t *   
)

◆ vlc_recvmsg_i11e()

ssize_t vlc_recvmsg_i11e ( int  fd,
struct msghdr *  ,
int  flags 
)

◆ vlc_sem_wait_i11e()

int vlc_sem_wait_i11e ( vlc_sem_t )

Interruptible variant of vlc_sem_wait().

Waits on a semaphore like vlc_sem_wait(). If the calling thread has an interruption context (as set by vlc_interrupt_set()), and another thread invokes vlc_interrupt_raise() on that context, the semaphore is incremented.

Warning
The calling thread should be the only thread ever to wait on the specified semaphore. Otherwise, interruptions may not be delivered accurately (the wrong thread may be woken up).
Note
This function is (always) a cancellation point.
Returns
EINTR if the semaphore was incremented due to an interruption, otherwise zero.

References vlc_cleanup_pop, vlc_cleanup_push, vlc_interrupt_cleanup(), vlc_interrupt_finish(), vlc_interrupt_prepare(), vlc_interrupt_sem(), vlc_interrupt_var, and vlc_sem_wait().

Referenced by vlc_getaddrinfo_i11e().

◆ vlc_send_i11e()

static ssize_t vlc_send_i11e ( int  fd,
const void *  buf,
size_t  len,
int  flags 
)
inlinestatic

◆ vlc_sendmsg_i11e()

ssize_t vlc_sendmsg_i11e ( int  fd,
const struct msghdr *  ,
int  flags 
)

◆ vlc_sendto_i11e()

ssize_t vlc_sendto_i11e ( int  fd,
const void *  ,
size_t  ,
int  flags,
const struct sockaddr *  ,
socklen_t   
)

◆ vlc_write_i11e()

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.

Note
Like write(), once some but not all bytes are written, the function might wait for write completion, regardless of signals and interruptions.
Warning
This function ignores the non-blocking file flag.

References vlc_writev_i11e().

Referenced by vlc_accept_i11e(), and vlc_msleep_i11e().

◆ vlc_writev_i11e()

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.

Note
Like writev(), once some but not all bytes are written, the function might wait for write completion, regardless of signals and interruptions.
Warning
This function ignores the non-blocking file flag.

References pollfd::events, pollfd::fd, POLLOUT, and vlc_poll_i11e().

Referenced by vlc_accept_i11e(), vlc_msleep_i11e(), and vlc_write_i11e().