Skip to content

Commit

Permalink
bpo-41687: Fix error handling in Solaris sendfile implementation (GH-…
Browse files Browse the repository at this point in the history
…22128)

I just realized that my recent PR with sendfile on Solaris ([PR 22040](#22040)) has broken error handling.

Sorry for that, this simple followup fixes that.

Automerge-Triggered-By: @1st1
  • Loading branch information
kulikjak authored Sep 9, 2020
1 parent 76553e5 commit fa8c9e7
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions Modules/posixmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit fa8c9e7

Please sign in to comment.