compare_and_swap() was too simple and has been deprecated

This commit is contained in:
Frank Denis 2021-02-12 19:20:01 +01:00
parent 741d28557d
commit b281555860
2 changed files with 6 additions and 2 deletions

View file

@ -43,7 +43,11 @@ impl ClientsCount {
let mut count;
while {
count = self.0.load(Ordering::Relaxed);
count > 0 && self.0.compare_and_swap(count, count - 1, Ordering::Relaxed) != count
count > 0
&& self
.0
.compare_exchange(count, count - 1, Ordering::Relaxed, Ordering::Relaxed)
!= Ok(count)
} {}
count
}

View file

@ -85,7 +85,7 @@ impl DoH {
server: Http<LocalExecutor>,
) -> Result<(), DoHError> {
let listener_service = async {
while let Ok((raw_stream, _client_addr)) = listener.accept().await {
while let Ok((raw_stream, _client_addr)) = listener.accept().await {
let stream = match tls_acceptor.accept(raw_stream).await {
Ok(stream) => stream,
Err(_) => continue,