Skip to content

Commit

Permalink
Use wrapping add in submission index
Browse files Browse the repository at this point in the history
After about 4.2 billion submission this will overflow, make sure it
wraps around instead.

Note that due to the masking done on the tail below this will keep
working after wrapping around back to zero.
  • Loading branch information
Thomasdezeeuw committed Jul 27, 2024
1 parent 42565a3 commit 39289c2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ impl SubmissionQueue {
.fetch_update(Ordering::AcqRel, Ordering::Acquire, |tail| {
if tail - kernel_read < shared.len {
// Still an entry available.
Some(tail + 1) // TODO: handle overflows.
Some(tail.wrapping_add(1))
} else {
None
}
Expand Down

0 comments on commit 39289c2

Please sign in to comment.