mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-02-22 03:12:27 +00:00
net_util: Use value returned from Queue::enable_notification()
This indicates if anything has been added to the available queue since it was last iterated through. If it returns true then it is necessary to iterate through the queue again otherwise it is appropriate to break out from the loop. Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
parent
2ed0338da8
commit
1fc3fef642
@ -62,6 +62,7 @@ impl CtrlQueue {
|
||||
access_platform: Option<&Arc<dyn AccessPlatform>>,
|
||||
) -> Result<bool> {
|
||||
let mut used_desc_heads = Vec::new();
|
||||
loop {
|
||||
for mut desc_chain in queue.iter().map_err(Error::QueueIterator)? {
|
||||
let ctrl_desc = desc_chain.next().ok_or(Error::NoControlHeaderDescriptor)?;
|
||||
|
||||
@ -145,9 +146,14 @@ impl CtrlQueue {
|
||||
queue
|
||||
.add_used(*desc_index, *len)
|
||||
.map_err(Error::QueueAddUsed)?;
|
||||
queue
|
||||
}
|
||||
|
||||
if !queue
|
||||
.enable_notification()
|
||||
.map_err(Error::QueueEnableNotification)?;
|
||||
.map_err(Error::QueueEnableNotification)?
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(!used_desc_heads.is_empty())
|
||||
|
@ -130,9 +130,12 @@ impl TxVirtio {
|
||||
queue
|
||||
.add_used(used_desc_head.0, used_desc_head.1)
|
||||
.map_err(NetQueuePairError::QueueAddUsed)?;
|
||||
queue
|
||||
if !queue
|
||||
.enable_notification()
|
||||
.map_err(NetQueuePairError::QueueEnableNotification)?;
|
||||
.map_err(NetQueuePairError::QueueEnableNotification)?
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(retry_write)
|
||||
@ -275,9 +278,12 @@ impl RxVirtio {
|
||||
queue
|
||||
.add_used(used_desc_head.0, used_desc_head.1)
|
||||
.map_err(NetQueuePairError::QueueAddUsed)?;
|
||||
queue
|
||||
if !queue
|
||||
.enable_notification()
|
||||
.map_err(NetQueuePairError::QueueEnableNotification)?;
|
||||
.map_err(NetQueuePairError::QueueEnableNotification)?
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(exhausted_descs)
|
||||
|
Loading…
x
Reference in New Issue
Block a user