From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 3CC8F72545 for ; Mon, 12 Apr 2021 15:55:48 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 256011FC8B for ; Mon, 12 Apr 2021 15:55:18 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id E72AE1FC7F for ; Mon, 12 Apr 2021 15:55:16 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id A684645A19 for ; Mon, 12 Apr 2021 15:55:16 +0200 (CEST) Date: Mon, 12 Apr 2021 15:55:15 +0200 From: Wolfgang Bumiller To: Dominik Csapak Cc: pbs-devel@lists.proxmox.com Message-ID: <20210412135515.htis6ekorkgszz34@wobu-vie.proxmox.com> References: <20210408122820.13492-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210408122820.13492-1-d.csapak@proxmox.com> User-Agent: NeoMutt/20180716 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.028 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pbs-devel] applied: [RFC PATCH proxmox-backup] tools/async_io: do not error on Accept for StaticIncoming X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Apr 2021 13:55:48 -0000 applied On Thu, Apr 08, 2021 at 02:28:20PM +0200, Dominik Csapak wrote: > 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 > --- > two remaining issues/questions: > > 1. maybe we want an accept loop in proxmox-backup-api akin to the one > in the proxy? this way we have better locality of the error logging, > more control of e.g. how many connections we accept, etc. > > 2. is it wise to log every failed connection attempt? i can very easily > generate massive logspam with a single line of 'ab'. shouldn't we > e.g. only log once a second how many connections were not accepted? > this is for the api as well as the proxy > > src/tools/async_io.rs | 14 ++++++++++---- > 1 file changed, 10 insertions(+), 4 deletions(-) > > diff --git a/src/tools/async_io.rs b/src/tools/async_io.rs > index 997c02fa..844afaa9 100644 > --- a/src/tools/async_io.rs > +++ b/src/tools/async_io.rs > @@ -6,6 +6,7 @@ use std::pin::Pin; > use std::task::{Context, Poll}; > > use futures::stream::{Stream, TryStream}; > +use futures::ready; > use tokio::io::{AsyncRead, AsyncWrite, ReadBuf}; > use tokio::net::TcpListener; > use hyper::client::connect::Connection; > @@ -108,10 +109,15 @@ impl hyper::server::accept::Accept for StaticIncoming { > self: Pin<&mut Self>, > cx: &mut Context, > ) -> Poll>> { > - match self.get_mut().0.poll_accept(cx) { > - Poll::Pending => Poll::Pending, > - Poll::Ready(Ok((conn, _addr))) => Poll::Ready(Some(Ok(conn))), > - Poll::Ready(Err(err)) => Poll::Ready(Some(Err(err))), > + let this = self.get_mut(); > + loop { > + match ready!(this.0.poll_accept(cx)) { > + Ok((conn, _addr)) => return Poll::Ready(Some(Ok(conn))), > + Err(err) => { > + eprintln!("error accepting connection: {}", err); > + continue; > + } > + } > } > } > } > -- > 2.20.1