From e463ad556cb35ee39b92dbf7d3934d4187ab70d2 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Sun, 16 Jun 2019 18:32:55 +0100 Subject: [Project] Rework HTTP IO --- src/libutil/libev_helper.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'src/libutil/libev_helper.c') diff --git a/src/libutil/libev_helper.c b/src/libutil/libev_helper.c index a0a0c509b..ac0f1fc0d 100644 --- a/src/libutil/libev_helper.c +++ b/src/libutil/libev_helper.c @@ -65,16 +65,26 @@ rspamd_ev_watcher_start (struct ev_loop *loop, ev_tstamp timeout) { ev->last_activity = ev_now (EV_A); - ev_timer_set (&ev->tm, timeout, 0.0); ev_io_start (EV_A_ &ev->io); - ev_timer_start (EV_A_ &ev->tm); + + if (timeout > 0) { + ev->timeout = timeout; + ev_timer_set (&ev->tm, timeout, 0.0); + ev_timer_start (EV_A_ &ev->tm); + } } void rspamd_ev_watcher_stop (struct ev_loop *loop, struct rspamd_io_ev *ev) { - ev_io_stop (EV_A_ &ev->io); + if (ev_is_pending (&ev->io) || ev_is_active (&ev->io)) { + ev_io_stop (EV_A_ &ev->io); + } + + if (ev->timeout > 0) { + ev_timer_stop (EV_A_ &ev->tm); + } } void -- cgit v1.2.3