Skip to content

Commit 0b47de1

Browse files
committed
fixup! [erts] Scheduler pollset migration only when single process enif_select
1 parent 93554ea commit 0b47de1

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

erts/emulator/sys/common/erl_check_io.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1253,6 +1253,7 @@ enif_select_x(ErlNifEnv* env,
12531253
ErtsDrvSelectDataState *free_select = NULL;
12541254
ErtsNifSelectDataState *free_nif = NULL;
12551255
ErtsPollEvents new_events = 0;
1256+
const Eterm recipient = pid ? pid->pid : env->proc->common.id;
12561257
#ifdef DEBUG_PRINT_MODE
12571258
char tmp_buff[255];
12581259
#endif
@@ -1345,6 +1346,8 @@ enif_select_x(ErlNifEnv* env,
13451346
old_events = state->events;
13461347

13471348
if (on) {
1349+
ASSERT(is_internal_pid(recipient));
1350+
13481351
if (state->type == ERTS_EV_TYPE_NONE)
13491352
ctl_op = ERTS_POLL_OP_ADD;
13501353
#if ERTS_POLL_USE_SCHEDULER_POLLING
@@ -1356,10 +1359,9 @@ enif_select_x(ErlNifEnv* env,
13561359
/* Check if this is a different process than last time.
13571360
* If so, reset the counter to prevent scheduler pollset migration
13581361
* in multi-process scenarios (e.g., multiple socket:accept callers). */
1359-
Eterm current_pid = env->proc->common.id;
1360-
if (state->last_select_pid != current_pid) {
1362+
if (state->last_select_pid != recipient) {
13611363
state->count = 0;
1362-
state->last_select_pid = current_pid;
1364+
state->last_select_pid = recipient;
13631365
}
13641366
else if (++(state->count) > 10) {
13651367
int wake_poller = 0;
@@ -1436,8 +1438,6 @@ enif_select_x(ErlNifEnv* env,
14361438
|| state->type == ERTS_EV_TYPE_NONE);
14371439

14381440
if (on) {
1439-
const Eterm recipient = pid ? pid->pid : env->proc->common.id;
1440-
ASSERT(is_internal_pid(recipient));
14411441
if (!state->driver.nif)
14421442
state->driver.nif = alloc_nif_select_data();
14431443
if (state->type == ERTS_EV_TYPE_NONE) {

0 commit comments

Comments
 (0)