drop states in block

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

View File

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