Issue #5661: Add a test for ECONNRESET/EPIPE handling to test_asyncore. Patch
authorCharles-François Natali <neologix@free.fr>
Sat, 29 Oct 2011 10:45:56 +0000 (12:45 +0200)
committerCharles-François Natali <neologix@free.fr>
Sat, 29 Oct 2011 10:45:56 +0000 (12:45 +0200)
by Xavier de Gaye.

Lib/test/test_asyncore.py
Misc/ACKS
Misc/NEWS

index 2c84a271f5b2760c1422aca968d774dc6588deb6..7bb594d039f05a6f3a7e1c5eb813c2a5c1d4048f 100644 (file)
@@ -632,6 +632,34 @@ class BaseTestAPI(unittest.TestCase):
         client = TestClient(self.family, server.address)
         self.loop_waiting_for_flag(client)
 
+    def test_handle_close_after_conn_broken(self):
+        # Check that ECONNRESET/EPIPE is correctly handled (issues #5661 and
+        # #11265).
+
+        data = b'\0' * 128
+
+        class TestClient(BaseClient):
+
+            def handle_write(self):
+                self.send(data)
+
+            def handle_close(self):
+                self.flag = True
+                self.close()
+
+        class TestHandler(BaseTestHandler):
+
+            def handle_read(self):
+                self.recv(len(data))
+                self.close()
+
+            def writable(self):
+                return False
+
+        server = BaseServer(self.family, self.addr, TestHandler)
+        client = TestClient(self.family, server.address)
+        self.loop_waiting_for_flag(client)
+
     @unittest.skipIf(sys.platform.startswith("sunos"),
                      "OOB support is broken on Solaris")
     def test_handle_expt(self):
index 2a62d9686454bbc151bd9b2d8ee75e4f9eb34ec1..821a8125912313d91f71f82b8a4315772e1dfb40 100644 (file)
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -225,6 +225,7 @@ Pierre-Yves David
 Scott David Daniels
 Ben Darnell
 Jonathan Dasteel
+Xavier de Gaye
 John DeGood
 Ned Deily
 Vincent Delft
index 92f8818eb49203a35ad94d30c19e46efe9263fcc..a821751308faed9029b979e65dbb11503baf40f8 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -1500,6 +1500,9 @@ Extension Modules
 Tests
 -----
 
+- Issue #5661: Add a test for ECONNRESET/EPIPE handling to test_asyncore. Patch
+  by Xavier de Gaye.
+
 - Issue #13218: Fix test_ssl failures on Debian/Ubuntu.
 
 - Re-enable lib2to3's test_parser.py tests, though with an expected failure