From: Remi Gacogne Date: Thu, 24 Apr 2025 11:45:14 +0000 (+0200) Subject: dnsdist: Properly handle buffering in the "max read IOs" test X-Git-Tag: dnsdist-2.0.0-alpha2~54^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F15462%2Fhead;p=thirdparty%2Fpdns.git dnsdist: Properly handle buffering in the "max read IOs" test It is completely possible that the entire query will be sent before the dnsdist process notices that the number of IOs is larger than the limit, closes the connection, and the test process is notified of the socket being closed (for example because of buffering). So we need to detect that the connection is closed during our attempt to read the response, rather than while we are sending the query. This commit does that, and also introduces a slight delay after sending each byte of the query, increasing the likelihood of the dnsdist process actually reading the query bytes one by one. --- diff --git a/regression-tests.dnsdist/test_TCPLimits.py b/regression-tests.dnsdist/test_TCPLimits.py index a549a273ed..c98d3641cd 100644 --- a/regression-tests.dnsdist/test_TCPLimits.py +++ b/regression-tests.dnsdist/test_TCPLimits.py @@ -168,13 +168,16 @@ class TestTCPLimitsReadIO(DNSDistTest): try: conn.send(payload[count].to_bytes()) count = count + 1 - except Exception as e: + time.sleep(0.001) + except: failed = True break if not failed: try: response = self.recvTCPResponseOverConnection(conn) + if not response: + failed = True except: failed = True @@ -188,7 +191,7 @@ class TestTCPLimitsReadIO(DNSDistTest): response = self.recvTCPResponseOverConnection(conn) if response is None: failed = True - except Exception as e: + except: failed = True finally: conn.close()