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

[RFC] Timer: Set EPOLLONESHOT for EPOLL_CTL_ADD after knote creation #10

Merged
merged 1 commit into from Jun 24, 2016

Conversation

ianpartridge
Copy link
Contributor

When using libkqueue, I see knote.c:153: knote_disable: Assertion '!(kn->kev.flags & 0x0008)' failed. (EV_DISABLE set twice on the same knote).

This patch ensures that EPOLLONESHOT is set on the ev.events if we are processing an EV_ONESHOT or EV_DISPATCH timer kevent. There is similar logic already in linux/write.c and linux/read.c

The patch resolves the assertion I am seeing. Comments very welcome as I am new to libkqueue. Thank you.

@mheily
Copy link
Owner

mheily commented May 27, 2016

Hi Ian,

Thanks for the patch! Just to let you know, I am a few weeks away from hitting a deadline on different project, and then I'm going out of town, so I can't take the time to test this out. I will get back to you by the end of June.

Sorry for the delay,

  • Mark

@@ -151,7 +151,10 @@ evfilt_timer_knote_create(struct filter *filt, struct knote *kn)
}

memset(&ev, 0, sizeof(ev));
ev.events = EPOLLIN;
ev.events = EPOLLIN | EPOLLET;
if (kn->kev.flags & EV_ONESHOT || kn->kev.flags & EV_DISPATCH)
Copy link

Choose a reason for hiding this comment

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

that seems wrong because of priority of operators in C. you should write this:

if (kn->kev.flags & (EV_ONESHOT | EV_DISPATCH))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if ((kn->kev.flags & EV_ONESHOT) || (kn->kev.flags & EV_DISPATCH))

is the desired logic.

Copy link

@MadCoder MadCoder Jun 8, 2016

Choose a reason for hiding this comment

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

I know, and it's completely equivalent to if (kn->kev.flags & (EV_ONESHOT | EV_DISPATCH)) ;)
but adding the parens also fixes it indeed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! PR updated.

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