If there is any error return 0
(meaning the timer is or has expired)
Signed-off-by: Angus Salkeld <asalkeld(a)redhat.com>
---
include/qb/qbloop.h | 2 ++
lib/loop_poll.c | 2 +-
lib/loop_timerlist.c | 4 ++--
3 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/include/qb/qbloop.h b/include/qb/qbloop.h
index 3b74616..6598885 100644
--- a/include/qb/qbloop.h
+++ b/include/qb/qbloop.h
@@ -136,6 +136,8 @@ int32_t qb_loop_timer_del(qb_loop_t *l, qb_loop_timer_handle th);
/**
* Get the time remaining before it expires.
*
+ * @note if the timer has already expired it will return 0
+ *
* @param l pointer to the loop instance
* @param th timer handle.
* @return nano seconds left
diff --git a/lib/loop_poll.c b/lib/loop_poll.c
index 3eabd99..e60b51d 100644
--- a/lib/loop_poll.c
+++ b/lib/loop_poll.c
@@ -805,7 +805,7 @@ uint64_t qb_loop_timer_expire_time_get(struct qb_loop *l,
qb_loop_timer_handle t
s = (struct qb_poll_source *)l->fd_source;
res = _poll_entry_from_handle_(s, th, &pe);
if (res != 0) {
- return res;
+ return 0;
}
if (timerfd_gettime(pe->ufd.fd, &its) == -1) {
diff --git a/lib/loop_timerlist.c b/lib/loop_timerlist.c
index 2579714..2792ec9 100644
--- a/lib/loop_timerlist.c
+++ b/lib/loop_timerlist.c
@@ -246,11 +246,11 @@ uint64_t qb_loop_timer_expire_time_get(struct qb_loop *l,
qb_loop_timer_handle t
res = _timer_from_handle_(s, th, &t);
if (res != 0) {
- return res;
+ return 0;
}
if (t->state != QB_POLL_ENTRY_ACTIVE) {
- return -EBADF;
+ return 0;
}
return timerlist_expire_time (&s->timerlist, t->timerlist_handle);
--
1.7.5.2