diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-06-21 16:03:59 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-06-22 10:57:29 +0100 |
commit | 76530e7356c3741bb91e482b4727f1fab68c817a (patch) | |
tree | 53dac89d746a53ddc0e85e0d3285d060464a18b8 | |
parent | 25707133ae54daec513c3f8e3a6090f74d6e3f67 (diff) | |
download | rspamd-76530e7356c3741bb91e482b4727f1fab68c817a.tar.gz rspamd-76530e7356c3741bb91e482b4727f1fab68c817a.zip |
[Minor] Fix some more issues with timeouts
-rw-r--r-- | src/libutil/libev_helper.c | 12 | ||||
-rw-r--r-- | src/lua/lua_tcp.c | 2 | ||||
-rw-r--r-- | src/rspamadm/lua_repl.c | 2 |
3 files changed, 11 insertions, 5 deletions
diff --git a/src/libutil/libev_helper.c b/src/libutil/libev_helper.c index 45e118e28..8a2cdc677 100644 --- a/src/libutil/libev_helper.c +++ b/src/libutil/libev_helper.c @@ -98,13 +98,17 @@ rspamd_ev_watcher_reschedule (struct ev_loop *loop, ev_io_start (EV_A_ &ev->io); } else { - ev_io_set (&ev->io, ev->io.fd, what); + ev->io.data = ev; + ev_io_init (&ev->io, rspamd_ev_watcher_io_cb, ev->io.fd, what); ev_io_start (EV_A_ &ev->io); } - if (!(ev_is_active (&ev->tm) || ev_is_pending (&ev->tm))) { - ev_timer_set (&ev->tm, ev->timeout, 0.0); - ev_timer_start (EV_A_ &ev->tm); + if (ev->timeout > 0) { + if (!(ev_is_active (&ev->tm) || ev_is_pending (&ev->tm))) { + ev->tm.data = ev; + ev_timer_init (&ev->tm, rspamd_ev_watcher_timer_cb, ev->timeout, 0.0); + ev_timer_start (EV_A_ &ev->tm); + } } ev->last_activity = ev_now (EV_A); diff --git a/src/lua/lua_tcp.c b/src/lua/lua_tcp.c index ab00548a0..b45d5b645 100644 --- a/src/lua/lua_tcp.c +++ b/src/lua/lua_tcp.c @@ -1275,6 +1275,8 @@ lua_tcp_make_connection (struct lua_tcp_cbdata *cbd) } } else { + rspamd_ev_watcher_init (&cbd->ev, cbd->fd, EV_READ|EV_WRITE, + lua_tcp_handler, cbd); lua_tcp_register_event (cbd); lua_tcp_plan_handler_event (cbd, TRUE, TRUE); } diff --git a/src/rspamadm/lua_repl.c b/src/rspamadm/lua_repl.c index 46fc342ea..59e3db02c 100644 --- a/src/rspamadm/lua_repl.c +++ b/src/rspamadm/lua_repl.c @@ -296,7 +296,7 @@ wait_session_events (void) { /* XXX: it's probably worth to add timeout here - not to wait forever */ while (rspamd_session_events_pending (rspamadm_session) > 0) { - ev_loop (rspamd_main->event_loop, EVLOOP_ONESHOT); + ev_loop (rspamd_main->event_loop, EVRUN_ONCE); } } |