Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

generate_request_id fixes #27

Merged
merged 2 commits into from
Mar 17, 2024
Merged

generate_request_id fixes #27

merged 2 commits into from
Mar 17, 2024

Conversation

g2p
Copy link
Contributor

@g2p g2p commented Mar 4, 2024

There was a race if generate_request_id was used with thread_safe.

While looking at that function, I also changed the types to ensure only strictly positive IDs are returned.

g2p added 2 commits March 4, 2024 19:03
The previous implementation dropped the first guard
before taking another, which could race.

It would be better to change to NonZeroU32 and checked_add as well
(wrapping issues).
Zero is for broadcast request_ids, change types to make it impossible
to return zero.  i32 wrapping does take a lot of requests, but this is neater.
Copy link
Owner

@azasypkin azasypkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@azasypkin azasypkin merged commit 62ab9cd into azasypkin:main Mar 17, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants