drop states in block

This commit is contained in:
2025-01-05 16:39:44 +08:00
parent 5d66f5dfc1
commit 568b2fbd70

View File

@@ -86,6 +86,7 @@ impl Downloader {
.map_err(|e| (StatusCode::INTERNAL_SERVER_ERROR, e.to_string()))?; .map_err(|e| (StatusCode::INTERNAL_SERVER_ERROR, e.to_string()))?;
// notify all waiters // notify all waiters
{
let mut states = self.states.lock().await; let mut states = self.states.lock().await;
let state = states.remove(target_url).unwrap(); let state = states.remove(target_url).unwrap();
state.result.lock().await.replace(Ok(DownloadData { state.result.lock().await.replace(Ok(DownloadData {
@@ -93,7 +94,7 @@ impl Downloader {
headers: headers.clone(), headers: headers.clone(),
})); }));
state.notify.notify_waiters(); state.notify.notify_waiters();
drop(states); }
Ok(DownloadData { body, headers }) Ok(DownloadData { body, headers })
} }