mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2025-02-06 10:32:10 +00:00
devices: virtio-iommu: do not hold RefCell or lock across async
Retrieve the translation response, which involves taking a mutable borrow of a RefCell as well as locking a Mutex, inside its own block so that the references are dropped before using await again. Fixes two new clippy warnings from Rust 1.61.0: - <https://rust-lang.github.io/rust-clippy/master/index.html#await_holding_refcell_ref> - <https://rust-lang.github.io/rust-clippy/master/index.html#await_holding_lock> BUG=None TEST=tools/clippy # Rust 1.61.0 Change-Id: If573af56968dceeae72a61a74f9f69dad8730364 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3671596 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Anton Romanov <romanton@google.com> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
This commit is contained in:
parent
8a4b2c448b
commit
900237a541
1 changed files with 21 additions and 19 deletions
|
@ -702,25 +702,27 @@ async fn handle_translate_request(
|
|||
iova,
|
||||
size,
|
||||
} = request_tube.next().await.map_err(IommuError::Tube)?;
|
||||
if let Some(mapper) = endpoints.borrow_mut().get(&endpoint_id) {
|
||||
response_tubes
|
||||
.get(&endpoint_id)
|
||||
.unwrap()
|
||||
.send(
|
||||
mapper
|
||||
.lock()
|
||||
.translate(iova, size)
|
||||
.map_err(|e| {
|
||||
error!("Failed to handle TranslateRequest: {}", e);
|
||||
e
|
||||
})
|
||||
.ok(),
|
||||
)
|
||||
.await
|
||||
.map_err(IommuError::Tube)?;
|
||||
} else {
|
||||
error!("endpoint_id {} not found", endpoint_id)
|
||||
}
|
||||
let translate_response: Option<Vec<MemRegion>> =
|
||||
if let Some(mapper) = endpoints.borrow_mut().get(&endpoint_id) {
|
||||
mapper
|
||||
.lock()
|
||||
.translate(iova, size)
|
||||
.map_err(|e| {
|
||||
error!("Failed to handle TranslateRequest: {}", e);
|
||||
e
|
||||
})
|
||||
.ok()
|
||||
} else {
|
||||
error!("endpoint_id {} not found", endpoint_id);
|
||||
continue;
|
||||
};
|
||||
|
||||
response_tubes
|
||||
.get(&endpoint_id)
|
||||
.unwrap()
|
||||
.send(translate_response)
|
||||
.await
|
||||
.map_err(IommuError::Tube)?;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue