Skip to content

Commit

Permalink
Fix a bug in SubmissionQueue::sync()
Browse files Browse the repository at this point in the history
The uring driver may update queue.head, so SubmissionQueue::sync()
should read queue.head instead of queue.tail.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
  • Loading branch information
jiangliu committed Dec 1, 2021
1 parent ab5dd5d commit 3f1628c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions io-uring-test/src/tests/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ pub fn test_nop(ring: &mut IoUring, test: &Test) -> anyhow::Result<()> {

unsafe {
let mut queue = ring.submission();
assert_eq!(queue.len(), 0);
queue.push(&nop_e).expect("queue is full");
assert_eq!(queue.len(), 1);
}

ring.submit_and_wait(1)?;
Expand All @@ -23,6 +25,12 @@ pub fn test_nop(ring: &mut IoUring, test: &Test) -> anyhow::Result<()> {
assert_eq!(cqes[0].user_data(), 0x42);
assert_eq!(cqes[0].result(), 0);

unsafe {
let mut queue = ring.submission();
queue.sync();
assert_eq!(queue.len(), 0);
}

Ok(())
}

Expand Down
1 change: 1 addition & 0 deletions src/squeue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ impl SubmissionQueue<'_> {
unsafe {
(*self.queue.tail).store(self.tail, atomic::Ordering::Release);
self.tail = (*self.queue.tail).load(atomic::Ordering::Acquire);
//self.head = (*self.queue.head).load(atomic::Ordering::Acquire);
}
}

Expand Down

0 comments on commit 3f1628c

Please sign in to comment.