From: Vsevolod Stakhov Date: Thu, 23 Oct 2025 15:46:26 +0000 (+0100) Subject: Revert "[Fix] Add fd validation in libev watcher functions to prevent invalid ev_io_s... X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=97a0c85af30a84eb7c655646b2278b780846c3b0;p=thirdparty%2Frspamd.git Revert "[Fix] Add fd validation in libev watcher functions to prevent invalid ev_io_start calls" This reverts commit b173a81524fa53101663b2b3b14af28f17d1316d. --- diff --git a/src/libutil/libev_helper.c b/src/libutil/libev_helper.c index 1d89251491..82fead9bb9 100644 --- a/src/libutil/libev_helper.c +++ b/src/libutil/libev_helper.c @@ -57,9 +57,7 @@ void rspamd_ev_watcher_start(struct ev_loop *loop, { g_assert(ev->cb != NULL); - if (ev->io.fd >= 0) { - ev_io_start(EV_A, &ev->io); - } + ev_io_start(EV_A, &ev->io); if (timeout > 0) { /* Update timestamp to avoid timers running early */ @@ -94,17 +92,15 @@ void rspamd_ev_watcher_reschedule(struct ev_loop *loop, { g_assert(ev->cb != NULL); - if (ev->io.fd >= 0) { - if (ev_can_stop(&ev->io)) { - ev_io_stop(EV_A, &ev->io); - ev_io_set(&ev->io, ev->io.fd, what); - ev_io_start(EV_A, &ev->io); - } - else { - 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_can_stop(&ev->io)) { + ev_io_stop(EV_A, &ev->io); + ev_io_set(&ev->io, ev->io.fd, what); + ev_io_start(EV_A, &ev->io); + } + else { + 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->timeout > 0) { @@ -126,17 +122,15 @@ void rspamd_ev_watcher_reschedule_at(struct ev_loop *loop, { g_assert(ev->cb != NULL); - if (ev->io.fd >= 0) { - if (ev_can_stop(&ev->io)) { - ev_io_stop(EV_A, &ev->io); - ev_io_set(&ev->io, ev->io.fd, what); - ev_io_start(EV_A, &ev->io); - } - else { - 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_can_stop(&ev->io)) { + ev_io_stop(EV_A, &ev->io); + ev_io_set(&ev->io, ev->io.fd, what); + ev_io_start(EV_A, &ev->io); + } + else { + 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 (at > 0) {