Skip to content

Commit b7e56ed

Browse files
committed
Fix: clippy && fmt
Signed-off-by: junxiang Mu <1948535941@qq.com>
1 parent 4811632 commit b7e56ed

File tree

2 files changed

+9
-16
lines changed

2 files changed

+9
-16
lines changed

crates/lock/src/guard.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -106,16 +106,15 @@ impl Drop for LockGuard {
106106
tracing::warn!("LockGuard channel send failed ({}), spawning fallback unlock task for {}", err, lock_id);
107107

108108
// If runtime is not available, this will panic; but in RustFS we are inside Tokio contexts.
109-
let _ = tokio::spawn(async move {
110-
let futures = clients
111-
.into_iter()
112-
.map(|client| {
113-
let id = lock_id.clone();
114-
async move { client.release(&id).await.unwrap_or(false) }
115-
})
116-
.collect::<Vec<_>>();
117-
let _ = futures::future::join_all(futures).await;
109+
let handle = tokio::spawn(async move {
110+
let futures_iter = clients.into_iter().map(|client| {
111+
let id = lock_id.clone();
112+
async move { client.release(&id).await.unwrap_or(false) }
113+
});
114+
let _ = futures::future::join_all(futures_iter).await;
118115
});
116+
// Explicitly drop the JoinHandle to acknowledge detaching the task.
117+
std::mem::drop(handle);
119118
}
120119
}
121120
}

crates/lock/src/local.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,7 @@ impl LocalLockMap {
9797
guard.remove(&k);
9898
}
9999
let wait = if due.is_empty() {
100-
next_deadline.and_then(|dl| {
101-
if dl > now {
102-
Some(dl - now)
103-
} else {
104-
Some(Duration::from_millis(0))
105-
}
106-
})
100+
next_deadline.map(|dl| if dl > now { dl - now } else { Duration::from_millis(0) })
107101
} else {
108102
Some(Duration::from_millis(0))
109103
};

0 commit comments

Comments
 (0)