From c7e2dfacc0618fffe14875c99408bd170fc95a6b Mon Sep 17 00:00:00 2001 From: wang384670111 <384670111@qq.com> Date: Tue, 9 Jan 2024 22:53:08 +0800 Subject: [PATCH] modify memory ordering --- ws/src/metadata.rs | 2 +- ws/src/session.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ws/src/metadata.rs b/ws/src/metadata.rs index 25b1bed82..c69fdf733 100644 --- a/ws/src/metadata.rs +++ b/ws/src/metadata.rs @@ -26,7 +26,7 @@ impl Sender { } fn check_active(&self) -> error::Result<()> { - if self.active.load(atomic::Ordering::SeqCst) { + if self.active.load(atomic::Ordering::Relaxed) { Ok(()) } else { Err(error::Error::ConnectionClosed) diff --git a/ws/src/session.rs b/ws/src/session.rs index eef7b0e9e..47e8cedb3 100644 --- a/ws/src/session.rs +++ b/ws/src/session.rs @@ -163,7 +163,7 @@ pub struct Session> { impl> Drop for Session { fn drop(&mut self) { - self.active.store(false, atomic::Ordering::SeqCst); + self.active.store(false, atomic::Ordering::Relaxed); if let Some(stats) = self.stats.as_ref() { stats.close_session(self.context.session_id) } @@ -274,14 +274,14 @@ where let response = self.handler.handle_request(req, metadata); let future = response.map(move |response| { - if !active_lock.load(atomic::Ordering::SeqCst) { + if !active_lock.load(atomic::Ordering::Relaxed) { return; } if let Some(result) = response { let res = out.send(result); match res { Err(error::Error::ConnectionClosed) => { - active_lock.store(false, atomic::Ordering::SeqCst); + active_lock.store(false, atomic::Ordering::Relaxed); } Err(e) => { warn!("Error while sending response: {:?}", e);