rspamd_upstream_ok(conn->server);
- /* Now wait for both read and write events */
+ /* Start reading; only arm EV_WRITE if there's queued data */
rspamd_ev_watcher_reschedule(conn->event_loop, &conn->ev,
- EV_READ | EV_WRITE);
+ g_queue_is_empty(conn->write_queue) ? EV_READ : EV_READ | EV_WRITE);
msg_debug("fuzzy_tcp: after reschedule - fd=%d, ev.io.fd=%d",
conn->fd, (int) conn->ev.io.fd);
fuzzy_tcp_read_handler(conn);
}
- /* Check for timed out pending requests */
- if (conn->connected) {
- fuzzy_tcp_check_pending_timeouts(conn->rule, conn->last_activity);
- }
-
FUZZY_TCP_RELEASE(conn);
}
}
}
- /* Queue is empty, no more data to write */
- /* Might want to disable EV_WRITE here if needed */
+ /* Queue is empty, switch to read-only to avoid busy-looping on EV_WRITE */
+ rspamd_ev_watcher_reschedule(conn->event_loop, &conn->ev, EV_READ);
}
/**