[pve-devel] [RFC PATCH] fix #3106: correctly queue incoming connections

Dietmar Maurer dietmar at proxmox.com
Wed Nov 4 06:37:12 CET 2020


Answering myself, this works as expected.

I now simply use Arc::new(()) to count references.

> On 11/03/2020 6:45 PM Dietmar Maurer <dietmar at proxmox.com> 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<bool> 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?





More information about the pve-devel mailing list