Skip to content

Commit 97aaf6f

Browse files
committed
introduce rb_ec_check_ints()
to avoid TLS issue with N:M threads.
1 parent 0d63b9b commit 97aaf6f

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

internal/thread.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ struct rb_io_close_wait_list {
6666
int rb_notify_fd_close(int fd, struct rb_io_close_wait_list *busy);
6767
void rb_notify_fd_close_wait(struct rb_io_close_wait_list *busy);
6868

69+
void rb_ec_check_ints(struct rb_execution_context_struct *ec);
70+
6971
RUBY_SYMBOL_EXPORT_BEGIN
7072

7173
void *rb_thread_prevent_fork(void *(*func)(void *), void *data); /* for ext/socket/raddrinfo.c */

ractor.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ ractor_check_ints(rb_execution_context_t *ec, rb_ractor_t *cr, ractor_sleep_clea
602602
enum ruby_tag_type state;
603603
EC_PUSH_TAG(ec);
604604
if ((state = EC_EXEC_TAG()) == TAG_NONE) {
605-
rb_thread_check_ints();
605+
rb_ec_check_ints(ec);
606606
}
607607
EC_POP_TAG();
608608

@@ -612,7 +612,7 @@ ractor_check_ints(rb_execution_context_t *ec, rb_ractor_t *cr, ractor_sleep_clea
612612
}
613613
}
614614
else {
615-
rb_thread_check_ints();
615+
rb_ec_check_ints(ec);
616616
}
617617
}
618618

thread.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1416,6 +1416,12 @@ rb_thread_wait_for(struct timeval time)
14161416
sleep_hrtime(th, rb_timeval2hrtime(&time), SLEEP_SPURIOUS_CHECK);
14171417
}
14181418

1419+
void
1420+
rb_ec_check_ints(rb_execution_context_t *ec)
1421+
{
1422+
RUBY_VM_CHECK_INTS_BLOCKING(ec);
1423+
}
1424+
14191425
/*
14201426
* CAUTION: This function causes thread switching.
14211427
* rb_thread_check_ints() check ruby's interrupts.
@@ -1426,7 +1432,7 @@ rb_thread_wait_for(struct timeval time)
14261432
void
14271433
rb_thread_check_ints(void)
14281434
{
1429-
RUBY_VM_CHECK_INTS_BLOCKING(GET_EC());
1435+
rb_ec_check_ints(GET_EC());
14301436
}
14311437

14321438
/*

0 commit comments

Comments
 (0)