]> granicus.if.org Git - python/commitdiff
bpo-30319: socket.close() now ignores ECONNRESET (#2565)
authorVictor Stinner <victor.stinner@gmail.com>
Tue, 4 Jul 2017 14:20:06 +0000 (16:20 +0200)
committerGitHub <noreply@github.com>
Tue, 4 Jul 2017 14:20:06 +0000 (16:20 +0200)
socket.close() was modified in Python 3.6 to raise OSError on
failure: see bpo-26685.

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 a1d829f9cb09a7117a27e794786e5260d8bf5abd..e18dd32d90045d80fc3efe2fd45b4669a5d446ca 100644 (file)
@@ -2696,7 +2696,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();
         }
     }