summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2018-02-01 14:07:08 (GMT)
committerAndrew Svetlov <andrew.svetlov@gmail.com>2018-02-01 14:07:08 (GMT)
commit3a04c52a9eb03e31c60037248b872f3662002a4d (patch)
tree45a38ce3f577dfb83ccbc06bd992c6d3c9dfb225 /Modules
parent8cf7ebb32dbdfb976ac92afd264e7587fb0da7ae (diff)
downloadcpython-3a04c52a9eb03e31c60037248b872f3662002a4d.zip
cpython-3a04c52a9eb03e31c60037248b872f3662002a4d.tar.gz
cpython-3a04c52a9eb03e31c60037248b872f3662002a4d.tar.bz2
bpo-31106: Fix handling of erros in posix_fallocate() and posix_fadvise() (GH-3000) (GH-3000) (#4101)
(cherry picked from commit d4b93e21c2664d6a78e0656e7a7be0807be1c352)
Diffstat (limited to 'Modules')
-rw-r--r--Modules/posixmodule.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 821b64c..e30d3c1 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -8792,11 +8792,16 @@ os_posix_fallocate_impl(PyObject *module, int fd, Py_off_t offset,
Py_BEGIN_ALLOW_THREADS
result = posix_fallocate(fd, offset, length);
Py_END_ALLOW_THREADS
- } while (result != 0 && errno == EINTR &&
- !(async_err = PyErr_CheckSignals()));
- if (result != 0)
- return (!async_err) ? posix_error() : NULL;
- Py_RETURN_NONE;
+ } while (result == EINTR && !(async_err = PyErr_CheckSignals()));
+
+ if (result == 0)
+ Py_RETURN_NONE;
+
+ if (async_err)
+ return NULL;
+
+ errno = result;
+ return posix_error();
}
#endif /* HAVE_POSIX_FALLOCATE) && !POSIX_FADVISE_AIX_BUG */
@@ -8834,11 +8839,16 @@ os_posix_fadvise_impl(PyObject *module, int fd, Py_off_t offset,
Py_BEGIN_ALLOW_THREADS
result = posix_fadvise(fd, offset, length, advice);
Py_END_ALLOW_THREADS
- } while (result != 0 && errno == EINTR &&
- !(async_err = PyErr_CheckSignals()));
- if (result != 0)
- return (!async_err) ? posix_error() : NULL;
- Py_RETURN_NONE;
+ } while (result == EINTR && !(async_err = PyErr_CheckSignals()));
+
+ if (result == 0)
+ Py_RETURN_NONE;
+
+ if (async_err)
+ return NULL;
+
+ errno = result;
+ return posix_error();
}
#endif /* HAVE_POSIX_FADVISE && !POSIX_FADVISE_AIX_BUG */