Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upEINTR handling #37
Comments
This comment has been minimized.
This comment has been minimized.
|
I would think that EINTR should probably be swallowed in the concrete
implementations like TcpStream I would think? Then no special handling
would be needed in tokio-io.
I'm interested in the thoughts of others re this topic
…On Sat, Apr 8, 2017 at 8:06 PM Siddharth Agarwal ***@***.***> wrote:
I wanted to bring EINTR (ErrorKind::Interrupted) handling up as a general
topic.
Traditionally, EINTR on Unix systems has meant that a signal has
interrupted this syscall. Usually, the operation can be immediately retried
(unlike EAGAIN/EWOULDBLOCK/WouldBlock which would have to be retried
later).
How should tokio-io handle EINTR, if at all? For example, this call
<https://github.com/tokio-rs/tokio-io/blob/d48c506a3edd13bc5b0bfa5e49bb53021d37c07c/src/framed_write.rs#L201>
in FramedWrite::poll_complete can fail with ErrorKind::Interrupted --
this means that a stream forwarding to a FramedWrite can fail with EINTR
at this point
<http://alexcrichton.com/futures-rs/src/futures/stream/forward.rs.html#80>.
This means that a Forward future when run with Core::run will fail and
consume the stream and sink, even though it can just be immediately retried.
- Should FramedWrite retry on ErrorKind::Interrupted?
- Should try_nb! and try_ready! retry on ErrorKind::Interrupted?
More general questions (perhaps more appropriate for other crates):
- Should Forward futures have some way to return the stream and sink
on error as well?
- How should this general pattern (Core::run gets passed a future
which errored out, but the future is still valid and poll can still be
called on it) be handled?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#37>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAAYJMu9_A8AFiokd75XCu6qCzK-vqCWks5ruEtIgaJpZM4M35zQ>
.
|
sunshowers
closed this
Apr 9, 2017
sunshowers
reopened this
Apr 9, 2017
This comment has been minimized.
This comment has been minimized.
|
(Whoops didn't mean to close this) That would require every AsyncRead and AsyncWrite to do its own EINTR handling, which means like much of the standard library like File would have to be wrapped. |
This comment has been minimized.
This comment has been minimized.
|
Yeah the intention is definitely that no one worries about EINTR handling in general. The standard library chose to expose EINTR from I think it's reasonable to follow a similar pattern in tokio where all combinators and such handle |
This comment has been minimized.
This comment has been minimized.
|
Do we even want to have EINTR in read / write. I see how this makes sense for std which is providing an API to use without a runtime but with tokio you are running in context of an executor and you probably don't want the thread to hit interrupts in the first place. I was thinking of swallowing EINTR in Read / write impls on TcpStream. |
This comment has been minimized.
This comment has been minimized.
|
OK, so it turns out that tokio-io must handle
|
This comment has been minimized.
This comment has been minimized.
|
That's what |
This comment has been minimized.
This comment has been minimized.
|
I've filed alexcrichton/bzip2-rs#18 and alexcrichton/flate2-rs#93. |
sunshowers
added a commit
to sunshowers/tokio-io
that referenced
this issue
Apr 10, 2017
This comment has been minimized.
This comment has been minimized.
|
Thanks for filing issues @sid0! Note that the comment in the docs there was largely targeted at atomicity. Basically if you successfully write any bytes then that must be reported back. I think it's fine, semantically, for an auto-retry to happen on EINTR. @carllerche you bring up a good point, tokio is less libstd-esque. I'd be fine auto-retrying on EINTR on TcpStream/TcpListener/UdpSocket. |
This comment has been minimized.
This comment has been minimized.
So this wasn't clear to me from the docs at all. If that is truly the intent then the docs should probably be updated to reflect that. I've opened up a topic on the internals board about that: https://internals.rust-lang.org/t/std-io-write-a-call-to-write-represents-at-most-one-attempt-to-write-to-any-wrapped-object/5068 |
This comment has been minimized.
This comment has been minimized.
|
What is the conclusion of this issue? Are there any action items? |
This comment has been minimized.
This comment has been minimized.
|
Yeah -- it should be documented that |
carllerche
added this to the v0.2 milestone
Dec 15, 2017
This comment has been minimized.
This comment has been minimized.
|
Would you be able to write up a PR with the doc changes and maybe check if tokio-core handles EINTR? |
This comment has been minimized.
This comment has been minimized.
Probably not any time soon, I'm afraid. |
This comment has been minimized.
This comment has been minimized.
|
The tokio-io crate has been moved into the tokio git repo. I created a new issue over there. See link above. |
sunshowers commentedApr 9, 2017
•
edited
I wanted to bring
EINTR(ErrorKind::Interrupted) handling up as a general topic.Traditionally,
EINTRon Unix systems has meant that a signal has interrupted this syscall. Usually, the operation can be immediately retried (unlikeEAGAIN/EWOULDBLOCK/WouldBlockwhich would have to be retried later).How should
tokio-iohandleEINTR, if at all? For example, this call inFramedWrite::poll_completecan fail withErrorKind::Interrupted-- this means that a stream forwarding to aFramedWritecan fail withEINTRat this point. This means that aForwardfuture when run withCore::runwill fail and consume the stream and sink, even though it can just be immediately retried.FramedWriteretry onErrorKind::Interrupted?try_nb!retry onErrorKind::Interrupted?More general questions (perhaps more appropriate for other crates):
Forwardfutures have some way to return the stream and sink on error as well?Core::rungets passed a future which errored out, but the future is still valid andpollcan still be called on it) be handled?