@@ -95,7 +95,7 @@ typedef enum {
9595 ERTS_EV_FLAG_IN_SCHEDULER = ERTS_EV_FLAG_CLEAR ,
9696 ERTS_EV_FLAG_NIF_SELECT = ERTS_EV_FLAG_CLEAR ,
9797#endif
98- #ifdef ERTS_POLL_USE_FALLBACK
98+ #ifdef ERTS_POLL_USE_FALLBACK /* This has to be an ifdef */
9999 ERTS_EV_FLAG_FALLBACK = 0x10 , /* Set when kernel poll rejected fd
100100 and it was put in the nkp version */
101101#else
@@ -1930,10 +1930,13 @@ erts_create_pollset_thread(int id, ErtsThrPrgrData *tpd) {
19301930}
19311931
19321932void
1933- erts_check_io (ErtsPollThread * psi , ErtsMonotonicTime timeout_time , int poll_only_thread )
1933+ erts_check_io (ErtsPollThread * psi , ErtsMonotonicTime timeout_time , bool needs_thread_progress )
19341934{
19351935 int pollres_len ;
19361936 int poll_ret , i ;
1937+ #if ERTS_POLL_USE_SCHEDULER_POLLING
1938+ bool is_scheduler_poll = psi -> ps == get_scheduler_pollset ();
1939+ #endif
19371940 ERTS_MSACC_PUSH_AND_SET_STATE (ERTS_MSACC_STATE_CHECK_IO );
19381941
19391942 restart :
@@ -1944,7 +1947,7 @@ erts_check_io(ErtsPollThread *psi, ErtsMonotonicTime timeout_time, int poll_only
19441947
19451948 pollres_len = psi -> pollres_len ;
19461949
1947- if (poll_only_thread )
1950+ if (needs_thread_progress )
19481951 erts_thr_progress_active (psi -> tpd , 0 );
19491952
19501953#if ERTS_POLL_USE_FALLBACK
@@ -1958,7 +1961,7 @@ erts_check_io(ErtsPollThread *psi, ErtsMonotonicTime timeout_time, int poll_only
19581961 poll_ret = erts_poll_wait (psi -> ps , psi -> pollres , & pollres_len , psi -> tpd , timeout_time );
19591962 }
19601963
1961- if (poll_only_thread )
1964+ if (needs_thread_progress )
19621965 erts_thr_progress_active (psi -> tpd , 1 );
19631966
19641967#ifdef ERTS_ENABLE_LOCK_CHECK
@@ -1982,9 +1985,6 @@ erts_check_io(ErtsPollThread *psi, ErtsMonotonicTime timeout_time, int poll_only
19821985 erl_errno_id (poll_ret ), poll_ret );
19831986 erts_send_error_to_logger_nogl (dsbufp );
19841987 }
1985- // if (is_normal_sched) {
1986- // erts_fprintf(stderr, "%d: woke up\r\n", esdp->no);
1987- // }
19881988 ERTS_MSACC_POP_STATE ();
19891989 return ;
19901990 }
@@ -2028,13 +2028,18 @@ erts_check_io(ErtsPollThread *psi, ErtsMonotonicTime timeout_time, int poll_only
20282028
20292029#if ERTS_POLL_USE_SCHEDULER_POLLING
20302030 if (state -> flags & ERTS_EV_FLAG_SCHEDULER ) {
2031- /* In the poll thread, this fd would have been disabled due to ONESHOT,
2032- but in the scheduler pollset it needs to be disabled manually. */
2033- int wake_poller = 0 ;
2034- erts_poll_control (get_scheduler_pollset (), fd , ERTS_POLL_OP_DEL , 0 , & wake_poller );
2035- state -> flags &= ~(ERTS_EV_FLAG_SCHEDULER |ERTS_EV_FLAG_IN_SCHEDULER );
2036- state -> count = 0 ;
2037- state -> last_select_pid = NIL ;
2031+ if (is_scheduler_poll ) {
2032+ /* If we triggered in a scheduler pollset,
2033+ then we should just remove it from the
2034+ scheduler pollset. */
2035+ int wake_poller = 0 ;
2036+ erts_poll_control (psi -> ps , fd , ERTS_POLL_OP_DEL , 0 , & wake_poller );
2037+ state -> flags &= ~(ERTS_EV_FLAG_SCHEDULER |ERTS_EV_FLAG_IN_SCHEDULER );
2038+ state -> count = 0 ;
2039+ state -> last_select_pid = NIL ;
2040+ } else {
2041+ state -> active_events = revents & ERTS_POLL_EV_IN ;
2042+ }
20382043 }
20392044#endif
20402045 } else {
@@ -2045,7 +2050,7 @@ erts_check_io(ErtsPollThread *psi, ErtsMonotonicTime timeout_time, int poll_only
20452050 revents &= state -> active_events | ERTS_POLL_EV_NVAL ;
20462051
20472052#if ERTS_POLL_USE_SCHEDULER_POLLING
2048- if (psi -> ps == get_scheduler_pollset () ) {
2053+ if (is_scheduler_poll ) {
20492054 if (!(state -> events & ERTS_POLL_EV_IN ) && state -> flags & ERTS_EV_FLAG_SCHEDULER ) {
20502055 /* If we triggered in a scheduler pollset and EV_IN is not set,
20512056 then we should just remove it from the scheduler pollset.
@@ -2176,7 +2181,7 @@ erts_check_io(ErtsPollThread *psi, ErtsMonotonicTime timeout_time, int poll_only
21762181
21772182 case ERTS_EV_TYPE_STOP_NIF : {
21782183#if ERTS_POLL_USE_SCHEDULER_POLLING
2179- if (psi -> ps == get_scheduler_pollset () )
2184+ if (is_scheduler_poll )
21802185 break ;
21812186#endif
21822187#if ERTS_POLL_USE_FALLBACK
@@ -2189,7 +2194,7 @@ erts_check_io(ErtsPollThread *psi, ErtsMonotonicTime timeout_time, int poll_only
21892194
21902195 case ERTS_EV_TYPE_STOP_USE : {
21912196#if ERTS_POLL_USE_SCHEDULER_POLLING
2192- if (psi -> ps == get_scheduler_pollset () )
2197+ if (is_scheduler_poll )
21932198 break ;
21942199#endif
21952200#if ERTS_POLL_USE_FALLBACK
0 commit comments