diff --git a/src/proto/ping_pong.rs b/src/proto/ping_pong.rs index e0442c838..844c5fbb9 100644 --- a/src/proto/ping_pong.rs +++ b/src/proto/ping_pong.rs @@ -211,11 +211,16 @@ impl ReceivedPing { impl UserPings { pub(crate) fn send_ping(&self) -> Result<(), Option> { - let prev = self.0.state.compare_and_swap( - USER_STATE_EMPTY, // current - USER_STATE_PENDING_PING, // new - Ordering::AcqRel, - ); + let prev = self + .0 + .state + .compare_exchange( + USER_STATE_EMPTY, // current + USER_STATE_PENDING_PING, // new + Ordering::AcqRel, + Ordering::Acquire, + ) + .unwrap_or_else(|v| v); match prev { USER_STATE_EMPTY => { @@ -234,11 +239,16 @@ impl UserPings { // Must register before checking state, in case state were to change // before we could register, and then the ping would just be lost. self.0.pong_task.register(cx.waker()); - let prev = self.0.state.compare_and_swap( - USER_STATE_RECEIVED_PONG, // current - USER_STATE_EMPTY, // new - Ordering::AcqRel, - ); + let prev = self + .0 + .state + .compare_exchange( + USER_STATE_RECEIVED_PONG, // current + USER_STATE_EMPTY, // new + Ordering::AcqRel, + Ordering::Acquire, + ) + .unwrap_or_else(|v| v); match prev { USER_STATE_RECEIVED_PONG => Poll::Ready(Ok(())), @@ -252,11 +262,16 @@ impl UserPings { impl UserPingsRx { fn receive_pong(&self) -> bool { - let prev = self.0.state.compare_and_swap( - USER_STATE_PENDING_PONG, // current - USER_STATE_RECEIVED_PONG, // new - Ordering::AcqRel, - ); + let prev = self + .0 + .state + .compare_exchange( + USER_STATE_PENDING_PONG, // current + USER_STATE_RECEIVED_PONG, // new + Ordering::AcqRel, + Ordering::Acquire, + ) + .unwrap_or_else(|v| v); if prev == USER_STATE_PENDING_PONG { self.0.pong_task.wake(); diff --git a/src/server.rs b/src/server.rs index 32433121a..f6b43ef08 100644 --- a/src/server.rs +++ b/src/server.rs @@ -1371,7 +1371,7 @@ impl proto::Peer for Peer { reason: Reason::PROTOCOL_ERROR, }); }} - }; + } b = b.version(Version::HTTP_2);