From 8a97993011fb93480233beb32128474218ff78fa Mon Sep 17 00:00:00 2001 From: Jakub Kulik Date: Mon, 7 Sep 2020 10:19:58 +0200 Subject: [PATCH] bpo-41687: Fix error handling in Solaris sendfile implementation --- Modules/posixmodule.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 00ba7580302bba..7c496938ed4c5e 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -9521,14 +9521,13 @@ os_sendfile_impl(PyObject *module, int out_fd, int in_fd, PyObject *offobj, #if defined(__sun) && defined(__SVR4) // On Solaris, sendfile raises EINVAL rather than returning 0 // when the offset is equal or bigger than the in_fd size. - int res; struct stat st; do { Py_BEGIN_ALLOW_THREADS - res = fstat(in_fd, &st); + ret = fstat(in_fd, &st); Py_END_ALLOW_THREADS - } while (res != 0 && errno == EINTR && !(async_err = PyErr_CheckSignals())); + } while (ret != 0 && errno == EINTR && !(async_err = PyErr_CheckSignals())); if (ret < 0) return (!async_err) ? posix_error() : NULL;