tools/async_io: do not error on Accept for StaticIncoming
in proxmox-backup-proxy, we log and discard any errors on 'accept', so that we can continue to server requests in proxmox-backup-api, we just have the StaticIncoming that accepts, which will forward any errors from the underlying TcpListener this patch also logs and discards the errors, like in the proxy. Otherwise it could happen that if the api-daemon has more files open than the proxy, it will shut itself down because of a 'too many open files' error if there are many open connections (the service should also restart on exit i think, but this is a separate issue) Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
parent
ce5327badc
commit
0417e9af1b
@ -6,6 +6,7 @@ use std::pin::Pin;
|
|||||||
use std::task::{Context, Poll};
|
use std::task::{Context, Poll};
|
||||||
|
|
||||||
use futures::stream::{Stream, TryStream};
|
use futures::stream::{Stream, TryStream};
|
||||||
|
use futures::ready;
|
||||||
use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};
|
use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};
|
||||||
use tokio::net::TcpListener;
|
use tokio::net::TcpListener;
|
||||||
use hyper::client::connect::Connection;
|
use hyper::client::connect::Connection;
|
||||||
@ -108,10 +109,15 @@ impl hyper::server::accept::Accept for StaticIncoming {
|
|||||||
self: Pin<&mut Self>,
|
self: Pin<&mut Self>,
|
||||||
cx: &mut Context,
|
cx: &mut Context,
|
||||||
) -> Poll<Option<Result<Self::Conn, Self::Error>>> {
|
) -> Poll<Option<Result<Self::Conn, Self::Error>>> {
|
||||||
match self.get_mut().0.poll_accept(cx) {
|
let this = self.get_mut();
|
||||||
Poll::Pending => Poll::Pending,
|
loop {
|
||||||
Poll::Ready(Ok((conn, _addr))) => Poll::Ready(Some(Ok(conn))),
|
match ready!(this.0.poll_accept(cx)) {
|
||||||
Poll::Ready(Err(err)) => Poll::Ready(Some(Err(err))),
|
Ok((conn, _addr)) => return Poll::Ready(Some(Ok(conn))),
|
||||||
|
Err(err) => {
|
||||||
|
eprintln!("error accepting connection: {}", err);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user