1
0
mirror of https://github.com/fafhrd91/actix-net synced 2024-11-27 16:52:58 +01:00
This commit is contained in:
Rob Ede 2022-01-28 21:46:17 +00:00
parent 3e624b8376
commit 941f67dec9
No known key found for this signature in database
GPG Key ID: 97C636207D3EF933
9 changed files with 35 additions and 32 deletions

View File

@ -193,7 +193,7 @@ impl<T, U> Framed<T, U> {
match this.codec.decode_eof(this.read_buf) { match this.codec.decode_eof(this.read_buf) {
Ok(Some(frame)) => return Poll::Ready(Some(Ok(frame))), Ok(Some(frame)) => return Poll::Ready(Some(Ok(frame))),
Ok(None) => return Poll::Ready(None), Ok(None) => return Poll::Ready(None),
Err(e) => return Poll::Ready(Some(Err(e))), Err(err) => return Poll::Ready(Some(Err(err))),
} }
} }
@ -204,7 +204,7 @@ impl<T, U> Framed<T, U> {
log::trace!("frame decoded from buffer"); log::trace!("frame decoded from buffer");
return Poll::Ready(Some(Ok(frame))); return Poll::Ready(Some(Ok(frame)));
} }
Err(e) => return Poll::Ready(Some(Err(e))), Err(err) => return Poll::Ready(Some(Err(err))),
_ => (), // Need more data _ => (), // Need more data
} }
@ -221,7 +221,7 @@ impl<T, U> Framed<T, U> {
let cnt = match tokio_util::io::poll_read_buf(this.io, cx, this.read_buf) { let cnt = match tokio_util::io::poll_read_buf(this.io, cx, this.read_buf) {
Poll::Pending => return Poll::Pending, Poll::Pending => return Poll::Pending,
Poll::Ready(Err(e)) => return Poll::Ready(Some(Err(e.into()))), Poll::Ready(Err(err)) => return Poll::Ready(Some(Err(err.into()))),
Poll::Ready(Ok(cnt)) => cnt, Poll::Ready(Ok(cnt)) => cnt,
}; };

View File

@ -50,7 +50,7 @@ impl Write for Bilateral {
assert_eq!(&data[..], &src[..data.len()]); assert_eq!(&data[..], &src[..data.len()]);
Ok(data.len()) Ok(data.len())
} }
Some(Err(e)) => Err(e), Some(Err(err)) => Err(err),
None => panic!("unexpected write; {:?}", src), None => panic!("unexpected write; {:?}", src),
} }
} }
@ -67,13 +67,13 @@ impl AsyncWrite for Bilateral {
buf: &[u8], buf: &[u8],
) -> Poll<Result<usize, io::Error>> { ) -> Poll<Result<usize, io::Error>> {
match Pin::get_mut(self).write(buf) { match Pin::get_mut(self).write(buf) {
Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => Pending, Err(ref err) if err.kind() == io::ErrorKind::WouldBlock => Pending,
other => Ready(other), other => Ready(other),
} }
} }
fn poll_flush(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<Result<(), io::Error>> { fn poll_flush(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<Result<(), io::Error>> {
match Pin::get_mut(self).flush() { match Pin::get_mut(self).flush() {
Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => Pending, Err(ref err) if err.kind() == io::ErrorKind::WouldBlock => Pending,
other => Ready(other), other => Ready(other),
} }
} }
@ -99,8 +99,8 @@ impl AsyncRead for Bilateral {
buf.put_slice(&data); buf.put_slice(&data);
Ready(Ok(())) Ready(Ok(()))
} }
Some(Err(ref e)) if e.kind() == WouldBlock => Pending, Some(Err(ref err)) if err.kind() == WouldBlock => Pending,
Some(Err(e)) => Ready(Err(e)), Some(Err(err)) => Ready(Err(err)),
None => Ready(Ok(())), None => Ready(Ok(())),
} }
} }

View File

@ -21,8 +21,8 @@ fn main() {
let server = let server =
Server::bind(&SocketAddr::from(([127, 0, 0, 1], 3000))).serve(make_service); Server::bind(&SocketAddr::from(([127, 0, 0, 1], 3000))).serve(make_service);
if let Err(e) = server.await { if let Err(err) = server.await {
eprintln!("server error: {}", e); eprintln!("server error: {}", err);
} }
}) })
} }

View File

@ -127,10 +127,10 @@ impl Accept {
let mut events = mio::Events::with_capacity(256); let mut events = mio::Events::with_capacity(256);
loop { loop {
if let Err(e) = self.poll.poll(&mut events, self.timeout) { if let Err(err) = self.poll.poll(&mut events, self.timeout) {
match e.kind() { match err.kind() {
io::ErrorKind::Interrupted => {} io::ErrorKind::Interrupted => {}
_ => panic!("Poll error: {}", e), _ => panic!("Poll error: {}", err),
} }
} }
@ -298,15 +298,15 @@ impl Accept {
fn register_logged(&self, info: &mut ServerSocketInfo) { fn register_logged(&self, info: &mut ServerSocketInfo) {
match self.register(info) { match self.register(info) {
Ok(_) => debug!("Resume accepting connections on {}", info.lst.local_addr()), Ok(_) => debug!("Resume accepting connections on {}", info.lst.local_addr()),
Err(e) => error!("Can not register server socket {}", e), Err(err) => error!("Can not register server socket {}", err),
} }
} }
fn deregister_logged(&self, info: &mut ServerSocketInfo) { fn deregister_logged(&self, info: &mut ServerSocketInfo) {
match self.poll.registry().deregister(&mut info.lst) { match self.poll.registry().deregister(&mut info.lst) {
Ok(_) => debug!("Paused accepting connections on {}", info.lst.local_addr()), Ok(_) => debug!("Paused accepting connections on {}", info.lst.local_addr()),
Err(e) => { Err(err) => {
error!("Can not deregister server socket {}", e) error!("Can not deregister server socket {}", err)
} }
} }
} }
@ -396,10 +396,10 @@ impl Accept {
let conn = Conn { io, token }; let conn = Conn { io, token };
self.accept_one(conn); self.accept_one(conn);
} }
Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => return, Err(ref err) if err.kind() == io::ErrorKind::WouldBlock => return,
Err(ref e) if connection_error(e) => continue, Err(ref err) if connection_error(err) => continue,
Err(e) => { Err(err) => {
error!("Error accepting connection: {}", e); error!("Error accepting connection: {}", err);
// deregister listener temporary // deregister listener temporary
self.deregister_logged(info); self.deregister_logged(info);

View File

@ -220,10 +220,10 @@ impl ServerBuilder {
{ {
// The path must not exist when we try to bind. // The path must not exist when we try to bind.
// Try to remove it to avoid bind error. // Try to remove it to avoid bind error.
if let Err(e) = std::fs::remove_file(addr.as_ref()) { if let Err(err) = std::fs::remove_file(addr.as_ref()) {
// NotFound is expected and not an issue. Anything else is. // NotFound is expected and not an issue. Anything else is.
if e.kind() != std::io::ErrorKind::NotFound { if err.kind() != std::io::ErrorKind::NotFound {
return Err(e); return Err(err);
} }
} }
@ -273,7 +273,7 @@ pub(super) fn bind_addr<S: ToSocketAddrs>(
success = true; success = true;
sockets.push(lst); sockets.push(lst);
} }
Err(e) => err = Some(e), Err(err) => err = Some(err),
} }
} }

View File

@ -77,8 +77,8 @@ where
}); });
Ok(()) Ok(())
} }
Err(e) => { Err(err) => {
error!("Can not convert to an async tcp stream: {}", e); error!("Can not convert to an async tcp stream: {}", err);
Err(()) Err(())
} }
}) })

View File

@ -97,7 +97,7 @@ where
match this.fut.poll(cx) { match this.fut.poll(cx) {
Poll::Ready(Ok(resp)) => Poll::Ready(Ok((this.f)(resp))), Poll::Ready(Ok(resp)) => Poll::Ready(Ok((this.f)(resp))),
Poll::Ready(Err(e)) => Poll::Ready(Err(e)), Poll::Ready(Err(err)) => Poll::Ready(Err(err)),
Poll::Pending => Poll::Pending, Poll::Pending => Poll::Pending,
} }
} }

View File

@ -141,9 +141,12 @@ where
trace!("SSL Handshake success: {:?}", stream.hostname()); trace!("SSL Handshake success: {:?}", stream.hostname());
Poll::Ready(Ok(stream.replace_io(this.io.take().unwrap()).1)) Poll::Ready(Ok(stream.replace_io(this.io.take().unwrap()).1))
} }
Err(e) => { Err(err) => {
trace!("SSL Handshake error: {:?}", e); trace!("SSL Handshake error: {:?}", err);
Poll::Ready(Err(io::Error::new(io::ErrorKind::Other, format!("{}", e)))) Poll::Ready(Err(io::Error::new(
io::ErrorKind::Other,
format!("{}", err),
)))
} }
} }
} }

View File

@ -164,8 +164,8 @@ impl<R: Host> Future for ResolverFut<R> {
Self::LookUp(fut, req) => { Self::LookUp(fut, req) => {
let res = match ready!(Pin::new(fut).poll(cx)) { let res = match ready!(Pin::new(fut).poll(cx)) {
Ok(Ok(res)) => Ok(res), Ok(Ok(res)) => Ok(res),
Ok(Err(e)) => Err(ConnectError::Resolver(Box::new(e))), Ok(Err(err)) => Err(ConnectError::Resolver(Box::new(err))),
Err(e) => Err(ConnectError::Io(e.into())), Err(err) => Err(ConnectError::Io(err.into())),
}; };
let req = req.take().unwrap(); let req = req.take().unwrap();