-
-
Notifications
You must be signed in to change notification settings - Fork 30.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bpo-31368: Expose preadv (preadv2) and pwritev (pwritev2) in the os module #5239
Changes from 1 commit
ea21128
4570976
21a3004
8a2a2a3
c0c53dc
4ddbca9
cac62ac
c7b7285
58910d0
f7cdf22
47f65b5
87c6970
cb74d38
5563b8d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8201,23 +8201,24 @@ os_preadv_impl(PyObject *module, int fd, PyObject *buffers, Py_off_t offset, | |
|
||
if (iov_setup(&iov, &buf, buffers, cnt, PyBUF_WRITABLE) < 0) | ||
return -1; | ||
#ifdef HAVE_PREADV2 | ||
#ifdef HAVE_PREADV2 | ||
do { | ||
Py_BEGIN_ALLOW_THREADS | ||
n = preadv2(fd, iov, cnt, offset, flags); | ||
Py_END_ALLOW_THREADS | ||
} while (n < 0 && errno == EINTR && !(async_err = PyErr_CheckSignals())); | ||
#else | ||
#else | ||
if(flags != 0){ | ||
PyErr_SetString(PyExc_OSError, "preadv2() not available in this system"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. PyExc_NotImplementedError is preferred on such case: maybe reuse argument_unavailable_error()? |
||
iov_cleanup(iov, buf, cnt); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you please this if(flags) before iov_setup() to not have to cleanup iov? Use #ifndef HAVE_PREADV2. |
||
return -1; | ||
} | ||
do { | ||
Py_BEGIN_ALLOW_THREADS | ||
n = preadv(fd, iov, cnt, offset); | ||
Py_END_ALLOW_THREADS | ||
} while (n < 0 && errno == EINTR && !(async_err = PyErr_CheckSignals())); | ||
#endif | ||
#endif | ||
|
||
iov_cleanup(iov, buf, cnt); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we exit early (e.g. due to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have corrected it in 4ddbca9. I could not use easily a goto label to have a clean exit section due to the check for async error in the signal handler so I just clean before exiting if |
||
if (n < 0) { | ||
|
@@ -8228,7 +8229,7 @@ os_preadv_impl(PyObject *module, int fd, PyObject *buffers, Py_off_t offset, | |
|
||
return n; | ||
} | ||
#endif /* HAVE_PREADV2 */ | ||
#endif /* HAVE_PREADV */ | ||
|
||
|
||
/*[clinic input] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you know if it's safe to call preadv2() again if it fals with EINTR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not completely sure. I assumed that it is the case because is implemented internally using
preadv
andpread
and those aresafe to retry but I cannot point to some place that definitely corroborates this. What should we do?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't worry. It's not really our issue for make sure that preadv()/preadv2() can be called again with same arguments on EINTR. The kernel and libc must make that doable and safe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't that how literally every syscall except
close
definesEINTR
? Alsopreadv2
doesn't even have any observable side-effects, it seems likepwritev2
is the one you should worry about if you're going to worry :-). (But ifpwritev2
manages to only write some of the bytes and then gets interrupted by a signal, then it should report a successful partial write, notEINTR
, the same waywrite
etc. work.)