Answering myself, this works as expected. I now simply use Arc::new(()) to count references.
> On 11/03/2020 6:45 PM Dietmar Maurer <diet...@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? _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel