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 two race conditions where an ASIO wakeup notifications can be lost #2561

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/libponyc/options/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,8 @@ static void usage(void)
" --ponythreads Use N scheduler threads. Defaults to the number of\n"
" cores (not hyperthreads) available.\n"
" --ponyminthreads Minimum number of active scheduler threads allowed.\n"
" Defaults to 0.\n"
" Defaults to 1. Use of 0 is considered experimental\n"
" and may cause improper scheduler behavior.\n"
" --ponycdmin Defer cycle detection until 2^N actors have blocked.\n"
" Defaults to 2^4.\n"
" --ponycdmax Always cycle detect when 2^N actors have blocked.\n"
Expand Down
6 changes: 6 additions & 0 deletions src/libponyrt/asio/epoll.c
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,13 @@ PONY_API void pony_asio_event_unsubscribe(asio_event_t* ev)
// tell scheduler threads that asio has no noisy actors
// if the old_count was 1
if (old_count == 1)
{
ponyint_sched_unnoisy_asio(SPECIAL_THREADID_EPOLL);

// maybe wake up a scheduler thread if they've all fallen asleep
ponyint_sched_maybe_wakeup_if_all_asleep(-1);
}

ev->noisy = false;
}

Expand Down
6 changes: 6 additions & 0 deletions src/libponyrt/asio/iocp.c
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,13 @@ PONY_API void pony_asio_event_unsubscribe(asio_event_t* ev)
// tell scheduler threads that asio has no noisy actors
// if the old_count was 1
if (old_count == 1)
{
ponyint_sched_unnoisy_asio(SPECIAL_THREADID_IOCP);

// maybe wake up a scheduler thread if they've all fallen asleep
ponyint_sched_maybe_wakeup_if_all_asleep(-1);
}

ev->noisy = false;
}

Expand Down
6 changes: 6 additions & 0 deletions src/libponyrt/asio/kqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,13 @@ PONY_API void pony_asio_event_unsubscribe(asio_event_t* ev)
// tell scheduler threads that asio has no noisy actors
// if the old_count was 1
if (old_count == 1)
{
ponyint_sched_unnoisy_asio(SPECIAL_THREADID_KQUEUE);

// maybe wake up a scheduler thread if they've all fallen asleep
ponyint_sched_maybe_wakeup_if_all_asleep(-1);
}

ev->noisy = false;
}

Expand Down
Loading