Skip to content

Commit 4940b9d

Browse files
committed
erts: Guard against IN events in poll thread
If an IN event is triggered in the poll thread just as migration happens to scheduler polling, we should just ignore that event as the scheduler poll will get the same event.
1 parent 96bc999 commit 4940b9d

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

erts/emulator/sys/common/erl_check_io.c

+12-4
Original file line numberDiff line numberDiff line change
@@ -1993,6 +1993,11 @@ erts_check_io(ErtsPollThread *psi, ErtsMonotonicTime timeout_time, int poll_only
19931993

19941994
DEBUG_PRINT_FD("triggered %s", state, ev2str(revents));
19951995

1996+
if (revents & ERTS_POLL_EV_IN && psi->ps != get_scheduler_pollset() &&
1997+
state->flags & ERTS_EV_FLAG_SCHEDULER) {
1998+
revents &= ~ERTS_POLL_EV_IN;
1999+
}
2000+
19962001
if (revents & ERTS_POLL_EV_ERR
19972002
&& !(state->flags & ERTS_EV_FLAG_WANT_ERROR)) {
19982003
/*
@@ -2037,14 +2042,17 @@ erts_check_io(ErtsPollThread *psi, ErtsMonotonicTime timeout_time, int poll_only
20372042
#endif
20382043
{
20392044
ErtsPollEvents reactive_events;
2045+
2046+
if (state->flags & ERTS_EV_FLAG_SCHEDULER) {
2047+
/* We are in a poll thread and the fd is managed
2048+
by a scheduler, we ignore the any IN events */
2049+
revents &= ~ERTS_POLL_EV_IN;
2050+
}
2051+
20402052
state->active_events &= ~revents;
20412053

20422054
reactive_events = state->active_events;
20432055

2044-
if (state->flags & ERTS_EV_FLAG_IN_SCHEDULER) {
2045-
state->active_events |= ERTS_POLL_EV_IN;
2046-
}
2047-
20482056
/* Reactivate the poll op if there are still active events */
20492057
if (reactive_events) {
20502058
ErtsPollEvents new_events;

0 commit comments

Comments
 (0)