diff options
Diffstat (limited to 'src/libutil')
-rw-r--r-- | src/libutil/libev_helper.c | 9 | ||||
-rw-r--r-- | src/libutil/libev_helper.h | 5 |
2 files changed, 10 insertions, 4 deletions
diff --git a/src/libutil/libev_helper.c b/src/libutil/libev_helper.c index 203e1ed73..82fead9bb 100644 --- a/src/libutil/libev_helper.c +++ b/src/libutil/libev_helper.c @@ -69,16 +69,21 @@ void rspamd_ev_watcher_start(struct ev_loop *loop, } } -void rspamd_ev_watcher_stop(struct ev_loop *loop, - struct rspamd_io_ev *ev) +ev_tstamp rspamd_ev_watcher_stop(struct ev_loop *loop, + struct rspamd_io_ev *ev) { + ev_tstamp elapsed = 0; + if (ev_can_stop(&ev->io)) { ev_io_stop(EV_A, &ev->io); } if (ev->timeout > 0) { + elapsed = ev->timeout - ev_timer_remaining(EV_A, &ev->tm); ev_timer_stop(EV_A, &ev->tm); } + + return elapsed; } void rspamd_ev_watcher_reschedule(struct ev_loop *loop, diff --git a/src/libutil/libev_helper.h b/src/libutil/libev_helper.h index d68f17951..be9917891 100644 --- a/src/libutil/libev_helper.h +++ b/src/libutil/libev_helper.h @@ -65,9 +65,10 @@ void rspamd_ev_watcher_start(struct ev_loop *loop, * Stops watcher and clean it up * @param loop * @param ev + * @return {ev_tstamp} elapsed time */ -void rspamd_ev_watcher_stop(struct ev_loop *loop, - struct rspamd_io_ev *ev); +ev_tstamp rspamd_ev_watcher_stop(struct ev_loop *loop, + struct rspamd_io_ev *ev); /** * Convenience function to reschedule watcher with different events |