mirror of
https://github.com/n0-computer/noq.git
synced 2026-09-17 08:45:12 +00:00
Fix the (pre-existing) rightward drift by inverting conditions
This commit is contained in:
committed by
Benjamin Saunders
parent
404db1bc94
commit
4b7a039499
+10
-10
@@ -927,18 +927,18 @@ impl Clone for ConnectionRef {
|
||||
|
||||
impl Drop for ConnectionRef {
|
||||
fn drop(&mut self) {
|
||||
let ref_count = self.shared.ref_count.fetch_sub(1, Ordering::Relaxed);
|
||||
if self.shared.ref_count.fetch_sub(1, Ordering::Relaxed) > 0 {
|
||||
return;
|
||||
}
|
||||
|
||||
if ref_count == 0 {
|
||||
let conn = &mut *self.state.lock("drop");
|
||||
let conn = &mut *self.state.lock("drop");
|
||||
|
||||
if !conn.inner.is_closed() {
|
||||
// If the driver is alive, it's just it and us, so we'd better shut it down. If it's
|
||||
// not, we can't do any harm. If there were any streams being opened, then either
|
||||
// the connection will be closed for an unrelated reason or a fresh reference will
|
||||
// be constructed for the newly opened stream.
|
||||
conn.implicit_close(&self.shared);
|
||||
}
|
||||
if !conn.inner.is_closed() {
|
||||
// If the driver is alive, it's just it and us, so we'd better shut it down. If it's
|
||||
// not, we can't do any harm. If there were any streams being opened, then either
|
||||
// the connection will be closed for an unrelated reason or a fresh reference will
|
||||
// be constructed for the newly opened stream.
|
||||
conn.implicit_close(&self.shared);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -770,15 +770,15 @@ impl Clone for EndpointRef {
|
||||
|
||||
impl Drop for EndpointRef {
|
||||
fn drop(&mut self) {
|
||||
let ref_count = self.shared.ref_count.fetch_sub(1, Ordering::Relaxed);
|
||||
if self.shared.ref_count.fetch_sub(1, Ordering::Relaxed) > 0 {
|
||||
return;
|
||||
}
|
||||
|
||||
if ref_count == 0 {
|
||||
let endpoint = &mut *self.0.state.lock().unwrap();
|
||||
// If the driver is about to be on its own, ensure it can shut down if the last
|
||||
// connection is gone.
|
||||
if let Some(task) = endpoint.driver.take() {
|
||||
task.wake();
|
||||
}
|
||||
let endpoint = &mut *self.0.state.lock().unwrap();
|
||||
// If the driver is about to be on its own, ensure it can shut down if the last
|
||||
// connection is gone.
|
||||
if let Some(task) = endpoint.driver.take() {
|
||||
task.wake();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user