From: Olivier Houchard Date: Wed, 18 Nov 2026 13:53:37 +0000 (+0100) Subject: BUG/MINOR: dns: detect the server's shutdown on a partial TCP response X-Git-Tag: v3.5-dev13~12 X-Git-Url: https://git.kaiwu.me/web/%22data:,/doc/static/%7B@url%7D?a=commitdiff_plain;h=44c1cdc8f5f8fdd0541e185a83149001183dd997;p=haproxy.git BUG/MINOR: dns: detect the server's shutdown on a partial TCP response When a DNS response is only partially received over TCP, the session's I/O handler reads the available data with applet_getblk() and waits for more. When nothing new is available, the requested length is zero, and applet_getblk() never reports the shutdown in this case since applet_may_get() only checks it when more data than available is requested. If the server closes after sending part of a response, the session then waits for data that will never come, and queries assigned to it are lost until it times out, about 20s later. Let's check for the shutdown when the message is incomplete: the rest cannot come anymore. This was brought in 3.3 by commit 217da087f ("MEDIUM: dns: Update the dns_session applet to use its own buffers"). It must be backported to 3.3. --- diff --git a/src/dns.c b/src/dns.c index 49665cf3b..093e02f70 100644 --- a/src/dns.c +++ b/src/dns.c @@ -753,6 +753,10 @@ static void dns_session_io_handler(struct appctx *appctx) if (applet_input_data(appctx) + ds->rx_msg.offset < ds->rx_msg.len) { /* message only partially available */ + /* the rest will never come once the server has shut */ + if (se_fl_test(appctx->sedesc, SE_FL_SHW)) + goto error; + /* read available data */ ret = applet_getblk(appctx, ds->rx_msg.area + ds->rx_msg.offset, applet_input_data(appctx), 0); if (ret <= 0) {