Skip to content

Added getters for the MqAttr struct#1619

Merged
bors[bot] merged 1 commit intonix-rust:masterfrom
fpagliughi:mqattr_getters
Dec 28, 2021
Merged

Added getters for the MqAttr struct#1619
bors[bot] merged 1 commit intonix-rust:masterfrom
fpagliughi:mqattr_getters

Conversation

@fpagliughi
Copy link
Copy Markdown
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
Copy Markdown
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!

Comment thread src/mqueue.rs
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
Copy Markdown
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
Copy Markdown
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.

@fpagliughi fpagliughi requested a review from rtzoeller December 27, 2021 15:38
@asomers
Copy link
Copy Markdown
Member

asomers commented Dec 27, 2021

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

@rtzoeller
Copy link
Copy Markdown
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