mirror of
https://github.com/troglobit/libuev.git
synced 2026-10-01 13:32:26 +07:00
Add support for signals using signalfd(2)
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
@@ -56,7 +56,7 @@ static struct timespec msec2tspec(int msec)
|
||||
* timer ends its life there, while a periodic task's @param timeout is
|
||||
* reset to the @param period and restarted.
|
||||
*
|
||||
* @return The new timer, or %NULL if invalid pointers or out or memory.
|
||||
* @return The new watcher, or %NULL with @param errno set on error.
|
||||
*/
|
||||
uev_watcher_t *uev_timer_create(uev_t *ctx, uev_cb_t *handler, void *data, int timeout, int period)
|
||||
{
|
||||
@@ -84,9 +84,11 @@ uev_watcher_t *uev_timer_create(uev_t *ctx, uev_cb_t *handler, void *data, int t
|
||||
/**
|
||||
* Reset or reschedule a timer
|
||||
* @param ctx A valid libuev context
|
||||
* @param w I/O watcher
|
||||
* @param w Watcher to reset
|
||||
* @param timeout Timeout in milliseconds before @param handler is called
|
||||
* @param period For periodic timers this is the period time that @param timeout is reset to
|
||||
*
|
||||
* @return POSIX OK(0) or non-zero with @param errno set.
|
||||
* @return POSIX OK(0) or non-zero with @param errno set on error.
|
||||
*/
|
||||
int uev_timer_set(uev_t *ctx, uev_watcher_t *w, int timeout, int period)
|
||||
{
|
||||
@@ -112,20 +114,25 @@ int uev_timer_set(uev_t *ctx, uev_watcher_t *w, int timeout, int period)
|
||||
/**
|
||||
* Delete a timer watcher
|
||||
* @param ctx A valid libuev context
|
||||
* @param w I/O watcher
|
||||
* @param w Watcher to delete
|
||||
*
|
||||
* @return POSIX OK(0) or non-zero with @param errno set.
|
||||
* @return POSIX OK(0) or non-zero with @param errno set on error.
|
||||
*/
|
||||
int uev_timer_delete(uev_t *ctx, uev_watcher_t *w)
|
||||
{
|
||||
int fd;
|
||||
|
||||
if (!ctx || !w) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
uev_timer_set(ctx, w, 0, 0);
|
||||
fd = w->fd;
|
||||
uev_watcher_delete(ctx, w);
|
||||
close(fd);
|
||||
|
||||
return uev_watcher_delete(ctx, w);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user