]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Properly handle buffering in the "max read IOs" test 15462/head
authorRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 24 Apr 2025 11:45:14 +0000 (13:45 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 24 Apr 2025 12:16:47 +0000 (14:16 +0200)
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.

regression-tests.dnsdist/test_TCPLimits.py

index a549a273ed9771842429f180c65e9c12e3449592..c98d3641cda62479b8adac3808d242710d236ea7 100644 (file)
@@ -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()