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

Added getters for the MqAttr struct #1619

Merged
merged 1 commit into from
Dec 28, 2021
Merged

Conversation

fpagliughi
Copy link
Contributor

@fpagliughi fpagliughi commented Dec 26, 2021

With the existing code, if you call mq_getattr(), there does not appear to be a way to get any of the attributes from the returned MqAttr struct, other than the flags. This adds getter functions to retrieve the size parameters of the queue, and the current number of messages in the queue.

Copy link
Collaborator

@rtzoeller rtzoeller left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! Can you update the changelog to include these changes?

I actually ran into the absence of these fields while looking into a failing test on DragonFly (and presumably NetBSD), so this change will also help clean up some tests in the future!

src/mqueue.rs Outdated
Comment on lines 78 to 81
/// The number of messages currently held in the queue
pub const fn current_msg(&self) -> mq_attr_member_t {
self.mq_attr.mq_curmsgs
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure how I feel about the naming here. cur is expanded to current, but we don't expand msg, and the underscores aren't present in the libc definitions.

For consistency with the rest of nix (example below), I'd lean towards using the same names as the underlying fields, minus the mq_ prefix. @asomers thoughts?

nix/src/sys/socket/addr.rs

Lines 1270 to 1273 in a392647

/// Packet type
pub fn pkttype(&self) -> u8 {
self.0.sll_pkttype
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm good with that. Seems more consistent. I can fix it.

@asomers
Copy link
Member

asomers commented Dec 27, 2021

LGTM. Just squash your commits and I'll merge it.

@rtzoeller
Copy link
Collaborator

bors r+

@bors bors bot merged commit c77a872 into nix-rust:master Dec 28, 2021
@fpagliughi fpagliughi deleted the mqattr_getters branch December 28, 2021 15:42
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.

3 participants