summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorКоренберг Марк <socketpair@gmail.com>2017-08-14 13:55:16 (GMT)
committerlarryhastings <larry@hastings.org>2017-08-14 13:55:16 (GMT)
commitd4b93e21c2664d6a78e0656e7a7be0807be1c352 (patch)
tree3297bc642116c0d5dba018c00a67123b380c4d48 /Modules
parent48d9823a0ebde4dfab8bc154bb6df462fb2ee403 (diff)
downloadcpython-d4b93e21c2664d6a78e0656e7a7be0807be1c352.zip
cpython-d4b93e21c2664d6a78e0656e7a7be0807be1c352.tar.gz
cpython-d4b93e21c2664d6a78e0656e7a7be0807be1c352.tar.bz2
bpo-31106: Fix handling of erros in posix_fallocate() and posix_fadvise() (#3000) (#3000)
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 2e5e79a..f057787 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -8917,11 +8917,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 */
@@ -8959,11 +8964,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 */