From: Vsevolod Stakhov Date: Mon, 8 Dec 2025 22:04:03 +0000 (+0000) Subject: [Fix] Only apply early response handling for HTTP clients X-Git-Tag: 3.14.2~4^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d2a8fbd7dbab5671801208cebb59f3cc22810e02;p=thirdparty%2Frspamd.git [Fix] Only apply early response handling for HTTP clients The early response detection logic should not run for server-side connections, as it incorrectly modifies wr_pos state when the server reads incoming requests. This was breaking spamc protocol handling. --- diff --git a/src/libserver/http/http_connection.c b/src/libserver/http/http_connection.c index 6e7bea1025..72ad56e76e 100644 --- a/src/libserver/http/http_connection.c +++ b/src/libserver/http/http_connection.c @@ -1003,8 +1003,9 @@ rspamd_http_event_handler(int fd, short what, gpointer ud) rspamd_http_connection_ref(conn); if (what & EV_READ) { - /* Check for early response while still sending request */ - if (priv->wr_pos < priv->wr_total && priv->wr_total > 0) { + /* Check for early response while still sending request (client only) */ + if (conn->type == RSPAMD_HTTP_CLIENT && + priv->wr_pos < priv->wr_total && priv->wr_total > 0) { msg_debug("received early server response while still writing request " "(sent %uz of %uz bytes)", priv->wr_pos, priv->wr_total); @@ -2501,8 +2502,9 @@ if (conn->opts & RSPAMD_HTTP_CLIENT_SSL) { } } else { - /* Watch for both READ and WRITE to detect early server responses */ - rspamd_ev_watcher_init(&priv->ev, conn->fd, EV_WRITE | EV_READ, + /* Watch for READ too on client to detect early server responses */ + short ev_flags = (conn->type == RSPAMD_HTTP_CLIENT) ? (EV_WRITE | EV_READ) : EV_WRITE; + rspamd_ev_watcher_init(&priv->ev, conn->fd, ev_flags, rspamd_http_event_handler, conn); /* Use connect_timeout on initial EV_WRITE stage if provided */ ev_tstamp start_to = (priv->connect_timeout > 0 ? priv->connect_timeout : priv->timeout);