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 race condition in kqueue event system implementation #2193

Merged
merged 4 commits into from Aug 26, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
33 changes: 24 additions & 9 deletions src/libponyrt/asio/kqueue.c
Expand Up @@ -161,28 +161,43 @@ DECLARE_THREAD_FN(ponyint_asio_backend_dispatch)
switch(ep->filter)
{
case EVFILT_READ:
ev->readable = true;
pony_asio_event_send(ev, ASIO_READ, 0);
if(ev->flags & ASIO_READ)
{
ev->readable = true;
pony_asio_event_send(ev, ASIO_READ, 0);
}
break;

case EVFILT_WRITE:
if(ep->flags & EV_EOF)
{
ev->readable = true;
ev->writeable = true;
pony_asio_event_send(ev, ASIO_READ | ASIO_WRITE, 0);
if(ev->flags & (ASIO_READ | ASIO_WRITE))
{
ev->readable = true;
ev->writeable = true;
pony_asio_event_send(ev, ASIO_READ | ASIO_WRITE, 0);
}
} else {
ev->writeable = true;
pony_asio_event_send(ev, ASIO_WRITE, 0);
if(ev->flags & ASIO_WRITE)
{
ev->writeable = true;
pony_asio_event_send(ev, ASIO_WRITE, 0);
}
}
break;

case EVFILT_TIMER:
pony_asio_event_send(ev, ASIO_TIMER, 0);
if(ev->flags & ASIO_TIMER)
{
pony_asio_event_send(ev, ASIO_TIMER, 0);
}
break;

case EVFILT_SIGNAL:
pony_asio_event_send(ev, ASIO_SIGNAL, (uint32_t)ep->data);
if(ev->flags & ASIO_SIGNAL)
{
pony_asio_event_send(ev, ASIO_SIGNAL, (uint32_t)ep->data);
}
break;

default: {}
Expand Down