]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Fix some more issues with timeouts
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 21 Jun 2019 15:03:59 +0000 (16:03 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 22 Jun 2019 09:57:29 +0000 (10:57 +0100)
src/libutil/libev_helper.c
src/lua/lua_tcp.c
src/rspamadm/lua_repl.c

index 45e118e288883a5667f1929d4d3503c6bd436f94..8a2cdc677c0ae0985304a4e9caefa3025932a37c 100644 (file)
@@ -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);
index ab00548a0ac8156ce12a7007d88e2813529480aa..b45d5b64561ce6313c802d07ccdb43c2cbf6b968 100644 (file)
@@ -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);
        }
index 46fc342eafa896cd5f266cc1a1e62ad1b811fb44..59e3db02c62a46f43368105150a06d1808a2fcc6 100644 (file)
@@ -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);
        }
 }