From: Vsevolod Stakhov Date: Fri, 21 Jun 2019 15:03:59 +0000 (+0100) Subject: [Minor] Fix some more issues with timeouts X-Git-Tag: 2.0~755^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=76530e7356c3741bb91e482b4727f1fab68c817a;p=thirdparty%2Frspamd.git [Minor] Fix some more issues with timeouts --- diff --git a/src/libutil/libev_helper.c b/src/libutil/libev_helper.c index 45e118e288..8a2cdc677c 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 ab00548a0a..b45d5b6456 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 46fc342eaf..59e3db02c6 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); } }