diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2013-10-17 17:04:51 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2013-10-24 14:21:57 -0700 |
| commit | 4eb53360541baf3e6df36dc0f0766bc7c1c9f8be (patch) | |
| tree | 0b78ce834f9df44297595d66b38883831811b99f /src/libstd/rt/io/native | |
| parent | 4ce71eaca34526d0e3ee1ebf0658d2a20d388ef2 (diff) | |
| download | rust-4eb53360541baf3e6df36dc0f0766bc7c1c9f8be.tar.gz rust-4eb53360541baf3e6df36dc0f0766bc7c1c9f8be.zip | |
Move as much I/O as possible off of native::io
When uv's TTY I/O is used for the stdio streams, the file descriptors are put into a non-blocking mode. This means that other concurrent writes to the same stream can fail with EAGAIN or EWOULDBLOCK. By all I/O to event-loop I/O, we avoid this error. There is one location which cannot move, which is the runtime's dumb_println function. This was implemented to handle the EAGAIN and EWOULDBLOCK errors and simply retry again and again.
Diffstat (limited to 'src/libstd/rt/io/native')
| -rw-r--r-- | src/libstd/rt/io/native/file.rs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/libstd/rt/io/native/file.rs b/src/libstd/rt/io/native/file.rs index d6820981181..a2b2289679a 100644 --- a/src/libstd/rt/io/native/file.rs +++ b/src/libstd/rt/io/native/file.rs @@ -21,6 +21,12 @@ fn raise_error() { // XXX: this should probably be a bit more descriptive... let (kind, desc) = match os::errno() as i32 { libc::EOF => (EndOfFile, "end of file"), + + // These two constants can have the same value on some systems, but + // different values on others, so we can't use a match clause + x if x == libc::EAGAIN || x == libc::EWOULDBLOCK => + (ResourceUnavailable, "resource temporarily unavailable"), + _ => (OtherIoError, "unknown error"), }; |
