From dbf8c0dae22e987d7ac91b5f11877a0e939b3f3a Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Sun, 19 Nov 2017 11:29:19 +0100 Subject: [PATCH] Doc: a timer must have a non-zero timeout value to be armed properly Signed-off-by: Joachim Nilsson --- API.md | 2 +- src/timer.c | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/API.md b/API.md index 044d839..1419734 100644 --- a/API.md +++ b/API.md @@ -69,7 +69,7 @@ int uev_io_set (uev_t *w, int fd, int events); int uev_io_start (uev_t *w); int uev_io_stop (uev_t *w); -/* Timer watcher: schedule a relative timer, timeout and period in milliseconds */ +/* Timer watcher: schedule a relative timer, timeout (must be non-zero) and period in milliseconds */ int uev_timer_init (uev_ctx_t *ctx, uev_t *w, uev_cb_t *cb, void *arg, int timeout, int period); int uev_timer_set (uev_t *w, int timeout, int period); /* Change timeout or period */ int uev_timer_start (uev_t *w); /* Restart a stopped timer */ diff --git a/src/timer.c b/src/timer.c index dad3d99..fddd5fc 100644 --- a/src/timer.c +++ b/src/timer.c @@ -93,9 +93,13 @@ int uev_timer_init(uev_ctx_t *ctx, uev_t *w, uev_cb_t *cb, void *arg, int timeou /** * Reset a timer * @param w Watcher to reset - * @param timeout Timeout in milliseconds before @param cb is called + * @param timeout Timeout in milliseconds before @param cb is called, zero disarms timer * @param period For periodic timers this is the period time that @param timeout is reset to * + * Note, the @param timeout value must be non-zero. Setting it to zero + * will disarm the timer. This is the underlying Linux function @func + * timerfd_settimer() which has this behavior. + * * @return POSIX OK(0) or non-zero with @param errno set on error. */ int uev_timer_set(uev_t *w, int timeout, int period)