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 8314065867 for ; Wed, 4 Nov 2020 06:37:54 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 80E10AC05 for ; Wed, 4 Nov 2020 06:37:54 +0100 (CET) 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) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 6FDC5ABF4 for ; Wed, 4 Nov 2020 06:37:53 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 3D74A45985 for ; Wed, 4 Nov 2020 06:37:53 +0100 (CET) Date: Wed, 4 Nov 2020 06:37:12 +0100 (CET) From: Dietmar Maurer To: Wolfgang Bumiller Cc: pve-devel@lists.proxmox.com Message-ID: <1080743137.733.1604468232474@webmail.proxmox.com> In-Reply-To: <641732415.729.1604425529102@webmail.proxmox.com> References: <20201103122636.2958-1-dietmar@proxmox.com> <20201103130552.dg4t2xaleylkzjq3@wobu-vie.proxmox.com> <641732415.729.1604425529102@webmail.proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Priority: 3 Importance: Normal X-Mailer: Open-Xchange Mailer v7.10.4-Rev12 X-Originating-Client: open-xchange-appsuite X-SPAM-LEVEL: Spam detection results: 0 AWL 0.067 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: Re: [pve-devel] [RFC PATCH] fix #3106: correctly queue incoming connections X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Nov 2020 05:37:54 -0000 Answering myself, this works as expected. I now simply use Arc::new(()) to count references. > On 11/03/2020 6:45 PM Dietmar Maurer wrote: > > > > > + Ok((sock, _addr)) => { > > > + sock.set_nodelay(true).unwrap(); > > > + let _ = set_tcp_keepalive(sock.as_raw_fd(), PROXMOX_BACKUP_TCP_KEEPALIVE_TIME); > > > + let acceptor = Arc::clone(&acceptor); > > > + let mut sender = sender.clone(); > > > + > > > + if accept_counter.load(Ordering::SeqCst) > MAX_PENDING_ACCEPTS { > > > + eprintln!("connection rejected - to many open connections"); > > > + continue; > > > + } > > > + accept_counter.fetch_add(1, Ordering::SeqCst); > > > > We should think about making a counter guard for this sort of thing, > > because from this point onward we're not allowed to use `?` anywhere, > > which is quite annoying. > > I wonder if we can simply use an Arc for that? The Arc already has > an atomic counter with deref on drop! > > And we can query that counter with Arc::strong_count > > What do you think?