Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fine-tune the Ordering for the atomic usages #684

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion ws/src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions ws/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ pub struct Session<M: core::Metadata, S: core::Middleware<M>> {

impl<M: core::Metadata, S: core::Middleware<M>> Drop for Session<M, S> {
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)
}
Expand Down Expand Up @@ -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);
Expand Down