summaryrefslogtreecommitdiffstats
path: root/src/libutil/libev_helper.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2019-06-16 18:32:55 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2019-06-22 10:57:29 +0100
commite463ad556cb35ee39b92dbf7d3934d4187ab70d2 (patch)
treea016f5503e746b586616d862c68ad233f262c6a9 /src/libutil/libev_helper.c
parent71e0dbf9608026c347279886097790e51e9e5506 (diff)
downloadrspamd-e463ad556cb35ee39b92dbf7d3934d4187ab70d2.tar.gz
rspamd-e463ad556cb35ee39b92dbf7d3934d4187ab70d2.zip
[Project] Rework HTTP IO
Diffstat (limited to 'src/libutil/libev_helper.c')
-rw-r--r--src/libutil/libev_helper.c16
1 files changed, 13 insertions, 3 deletions
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