diff options
author | Jakub KulĂk <Kulikjak@gmail.com> | 2020-09-05 19:10:01 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-05 19:10:01 (GMT) |
commit | 8c0be6fd9101746235b63ddfb84106d1e9ca286b (patch) | |
tree | e4559bbc18f13fd971dc4136c71e3729664c2896 /Modules/posixmodule.c | |
parent | dd18001c308fb3bb65006c91d95f6639583a3420 (diff) | |
download | cpython-8c0be6fd9101746235b63ddfb84106d1e9ca286b.zip cpython-8c0be6fd9101746235b63ddfb84106d1e9ca286b.tar.gz cpython-8c0be6fd9101746235b63ddfb84106d1e9ca286b.tar.bz2 |
bpo-41687: Fix sendfile implementation to work with Solaris (#22040)
Diffstat (limited to 'Modules/posixmodule.c')
-rw-r--r-- | Modules/posixmodule.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index a6a4b9f..00ba758 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -9518,6 +9518,25 @@ done: if (!Py_off_t_converter(offobj, &offset)) return NULL; +#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); + Py_END_ALLOW_THREADS + } while (res != 0 && errno == EINTR && !(async_err = PyErr_CheckSignals())); + if (ret < 0) + return (!async_err) ? posix_error() : NULL; + + if (offset >= st.st_size) { + return Py_BuildValue("i", 0); + } +#endif + do { Py_BEGIN_ALLOW_THREADS ret = sendfile(out_fd, in_fd, &offset, count); |