Fix the (pre-existing) rightward drift by inverting conditions

This commit is contained in:
Perelyn
2026-01-12 03:22:04 +01:00
committed by Benjamin Saunders
parent 404db1bc94
commit 4b7a039499
2 changed files with 18 additions and 18 deletions
+10 -10
View File
@@ -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);
}
}
}
+8 -8
View File
@@ -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();
}
}
}