mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-25 00:00:18 +02:00
Change need_read and need_write to return an error
This commit is targeted at solving tokio-rs/tokio-core#12 and incorporates the solution from tokio-rs/tokio-core#17. Namely the `need_read` and `need_write` functions on `PollEvented` now return an error when the connected reactor has gone away and the task cannot be blocked. This will typically naturally translate to errors being returned by various connected I/O objects and should help tear down the world in a clean-ish fashion.
This commit is contained in:
+3
-3
@@ -64,7 +64,7 @@ impl TcpListener {
|
||||
match self.io.get_ref().accept() {
|
||||
Err(e) => {
|
||||
if e.kind() == io::ErrorKind::WouldBlock {
|
||||
self.io.need_read();
|
||||
self.io.need_read()?;
|
||||
}
|
||||
Err(e)
|
||||
},
|
||||
@@ -576,7 +576,7 @@ impl<'a> AsyncRead for &'a TcpStream {
|
||||
Ok(Async::Ready(n))
|
||||
}
|
||||
Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => {
|
||||
self.io.need_read();
|
||||
self.io.need_read()?;
|
||||
Ok(Async::NotReady)
|
||||
}
|
||||
Err(e) => Err(e),
|
||||
@@ -614,7 +614,7 @@ impl<'a> AsyncWrite for &'a TcpStream {
|
||||
Ok(Async::Ready(n))
|
||||
}
|
||||
Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => {
|
||||
self.io.need_write();
|
||||
self.io.need_write()?;
|
||||
Ok(Async::NotReady)
|
||||
}
|
||||
Err(e) => Err(e),
|
||||
|
||||
+4
-4
@@ -93,7 +93,7 @@ impl UdpSocket {
|
||||
Ok(n) => Ok(n),
|
||||
Err(e) => {
|
||||
if e.kind() == io::ErrorKind::WouldBlock {
|
||||
self.io.need_write();
|
||||
self.io.need_write()?;
|
||||
}
|
||||
Err(e)
|
||||
}
|
||||
@@ -115,7 +115,7 @@ impl UdpSocket {
|
||||
Ok(n) => Ok(n),
|
||||
Err(e) => {
|
||||
if e.kind() == io::ErrorKind::WouldBlock {
|
||||
self.io.need_read();
|
||||
self.io.need_read()?;
|
||||
}
|
||||
Err(e)
|
||||
}
|
||||
@@ -163,7 +163,7 @@ impl UdpSocket {
|
||||
Ok(n) => Ok(n),
|
||||
Err(e) => {
|
||||
if e.kind() == io::ErrorKind::WouldBlock {
|
||||
self.io.need_write();
|
||||
self.io.need_write()?;
|
||||
}
|
||||
Err(e)
|
||||
}
|
||||
@@ -205,7 +205,7 @@ impl UdpSocket {
|
||||
Ok(n) => Ok(n),
|
||||
Err(e) => {
|
||||
if e.kind() == io::ErrorKind::WouldBlock {
|
||||
self.io.need_read();
|
||||
self.io.need_read()?;
|
||||
}
|
||||
Err(e)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user