]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-30319: socket.close() now ignores ECONNRESET (#2565) (#2566)
authorVictor Stinner <victor.stinner@gmail.com>
Tue, 4 Jul 2017 14:46:10 +0000 (16:46 +0200)
committerGitHub <noreply@github.com>
Tue, 4 Jul 2017 14:46:10 +0000 (16:46 +0200)
socket.close() was modified in Python 3.6 to raise OSError on
failure: see bpo-26685.
(cherry picked from commit 67e1478dba6efe60b8e1890192014b8b06dd6bd9)

Misc/NEWS.d/next/Library/2017-07-04-13-48-21.bpo-30319.hg_3TX.rst [new file with mode: 0644]
Modules/socketmodule.c

diff --git a/Misc/NEWS.d/next/Library/2017-07-04-13-48-21.bpo-30319.hg_3TX.rst b/Misc/NEWS.d/next/Library/2017-07-04-13-48-21.bpo-30319.hg_3TX.rst
new file mode 100644 (file)
index 0000000..1112d2f
--- /dev/null
@@ -0,0 +1 @@
+socket.close() now ignores ECONNRESET error.
index 42aec59ca7f6e59a50da89f3772e3db52c964e99..d006bd4def3ce4009b3ca64c673042c4a387b108 100644 (file)
@@ -2704,7 +2704,9 @@ sock_close(PySocketSockObject *s)
         Py_BEGIN_ALLOW_THREADS
         res = SOCKETCLOSE(fd);
         Py_END_ALLOW_THREADS
-        if (res < 0) {
+        /* bpo-30319: The peer can already have closed the connection.
+           Python ignores ECONNRESET on close(). */
+        if (res < 0 && errno != ECONNRESET) {
             return s->errorhandler();
         }
     }