drop states in block
This commit is contained in:
17
src/main.rs
17
src/main.rs
@@ -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 })
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user