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

fix #480 and add simple test cases for that. #486

Merged
merged 8 commits into from
Jan 11, 2017
Merged

fix #480 and add simple test cases for that. #486

merged 8 commits into from
Jan 11, 2017

Conversation

hicqu
Copy link
Contributor

@hicqu hicqu commented Dec 8, 2016

r? @fiveop

Copy link
Contributor

@fiveop fiveop left a comment

Choose a reason for hiding this comment

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

I have just one question and one change request. Looks good otherwise.

Could you rebase to master, before pushing again (with -f), so that the CI will not expect the 1.7 builds to work.

pub fn epoll_ctl<'a, T>(epfd: RawFd, op: EpollOp, fd: RawFd, event: T) -> Result<()>
where T: Into<&'a mut EpollEvent>
{
let res = unsafe { libc::epoll_ctl(epfd, op as c_int, fd, &mut event.into().event) };
Copy link
Contributor

Choose a reason for hiding this comment

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

In order for this to be safe, we should check, if op is EPOLL_CTL_DEL when event is NONE. Otherwise we might pass a null pointer into libc::epoll_ctl, when it expects something else.

EpollEvent { event: libc::epoll_event { events: events.bits(), u64: data } }
}

pub fn empty() -> Self {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you give me an example of a use case for this function?

@hicqu
Copy link
Contributor Author

hicqu commented Dec 11, 2016

EpollEvent::empty() is a try for simplify this case:

let mut events: [EpollEvent; 128] = [EpollEvent::new(EpollFlags::empty(), 0 as u64); 128];
epoll_wait(epoll_fd, &mut events, -1);

Do you think that's a good idea? Maybe I should move that to another issue for more deep discussion.

As for another question, we should return an error when call epoll_ctl(epoll_fd, EpollOp::EpollCtlAdd, None) or just panic!()? I think return an error is a good idea. So which error should be return do you think?

@hicqu
Copy link
Contributor Author

hicqu commented Dec 11, 2016

Sorry for forgeting to edit CHANGLOG. If all design are reviewed and OK, I will complete that.

@fiveop
Copy link
Contributor

fiveop commented Dec 16, 2016

I would return EINVAL in case op and event don't fit together. But we need to document that properly on that function.

@hicqu
Copy link
Contributor Author

hicqu commented Dec 17, 2016

Got it. I will fix all and make pull request again. Thank you!

@hicqu
Copy link
Contributor Author

hicqu commented Dec 19, 2016

I think everything is OK. Please check it again. Thanks!

@hicqu
Copy link
Contributor Author

hicqu commented Dec 31, 2016

Anything wrong?

@fiveop
Copy link
Contributor

fiveop commented Jan 11, 2017

No. I have not looked into this project for a while. Sorry.

@homu r=fiveop

@homu
Copy link
Contributor

homu commented Jan 11, 2017

📌 Commit acc1513 has been approved by fiveop

homu added a commit that referenced this pull request Jan 11, 2017
fix #480 and add simple test cases for that.

r? @fiveop
@homu
Copy link
Contributor

homu commented Jan 11, 2017

⌛ Testing commit acc1513 with merge 1fbf1fe...

@homu
Copy link
Contributor

homu commented Jan 11, 2017

☀️ Test successful - status

@homu homu merged commit acc1513 into nix-rust:master Jan 11, 2017
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.

None yet

3 participants