mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2025-02-11 12:35:26 +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,
|
iova,
|
||||||
size,
|
size,
|
||||||
} = request_tube.next().await.map_err(IommuError::Tube)?;
|
} = request_tube.next().await.map_err(IommuError::Tube)?;
|
||||||
if let Some(mapper) = endpoints.borrow_mut().get(&endpoint_id) {
|
let translate_response: Option<Vec<MemRegion>> =
|
||||||
response_tubes
|
if let Some(mapper) = endpoints.borrow_mut().get(&endpoint_id) {
|
||||||
.get(&endpoint_id)
|
mapper
|
||||||
.unwrap()
|
.lock()
|
||||||
.send(
|
.translate(iova, size)
|
||||||
mapper
|
.map_err(|e| {
|
||||||
.lock()
|
error!("Failed to handle TranslateRequest: {}", e);
|
||||||
.translate(iova, size)
|
e
|
||||||
.map_err(|e| {
|
})
|
||||||
error!("Failed to handle TranslateRequest: {}", e);
|
.ok()
|
||||||
e
|
} else {
|
||||||
})
|
error!("endpoint_id {} not found", endpoint_id);
|
||||||
.ok(),
|
continue;
|
||||||
)
|
};
|
||||||
.await
|
|
||||||
.map_err(IommuError::Tube)?;
|
response_tubes
|
||||||
} else {
|
.get(&endpoint_id)
|
||||||
error!("endpoint_id {} not found", endpoint_id)
|
.unwrap()
|
||||||
}
|
.send(translate_response)
|
||||||
|
.await
|
||||||
|
.map_err(IommuError::Tube)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue