From ba796e3c71084f051c3046b17d07a6f9b7731795 Mon Sep 17 00:00:00 2001 From: Vladimir Dubrovin <3proxy@3proxy.ru> Date: Tue, 24 Nov 2026 19:09:20 +0300 Subject: [PATCH] portmap: the half-closed client's check says when it timed out MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The whole answer behind a 32 K window, delivered to a client asleep for a second, can take longer than the thirty seconds its socket waited for on a busy runner — and the timeout, caught with every other error, looked like an answer cut short, a bug where there was none. The answer is four megabytes now, a quarter of it before, and a timeout is told apart: it says so, with how much had arrived. --- tests/cases/portmap.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/tests/cases/portmap.py b/tests/cases/portmap.py index 3e3aaa8..ce8e5ae 100644 --- a/tests/cases/portmap.py +++ b/tests/cases/portmap.py @@ -4,7 +4,7 @@ import socket import threading import time -HALFCLOSE_SIZE = 20000000 +HALFCLOSE_SIZE = 4000000 def halfclose_origin(listener): @@ -81,8 +81,9 @@ def run(t): """, ports=[halfclosed]) s = socket.socket() s.setsockopt(socket.SOL_SOCKET, socket.SO_RCVBUF, 32768) - s.settimeout(30) + s.settimeout(60) got = 0 + timedout = False try: s.connect(("127.0.0.1", halfclosed)) s.sendall(b"request") @@ -93,11 +94,18 @@ def run(t): if not d: break got += len(d) + except socket.timeout: + timedout = True except OSError: pass s.close() listener.close() - t.eq(HALFCLOSE_SIZE, got, "a half-closed client reading slowly gets the whole answer") + if timedout: + t.fail("a half-closed client reading slowly gets the whole answer", + f"{HALFCLOSE_SIZE} bytes", f"timed out with {got}") + else: + t.eq(HALFCLOSE_SIZE, got, + "a half-closed client reading slowly gets the whole answer") t.stop_all()