Skip to content

Commit

Permalink
MN: access timer_th.waiting with lock
Browse files Browse the repository at this point in the history
`timer_th.waiting` should be protected by `timer_th.waiting_lock`
  • Loading branch information
ko1 committed Dec 24, 2023
1 parent daefbf8 commit 8201549
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions thread_pthread_mn.c
Expand Up @@ -660,10 +660,6 @@ timer_thread_register_waiting(rb_thread_t *th, int fd, enum thread_sched_waiting
#if HAVE_SYS_EVENT_H
struct kevent ke[2];
int num_events = 0;

if (kqueue_already_registered(fd)) {
return false;
}
#else
uint32_t epoll_events = 0;
#endif
Expand Down Expand Up @@ -708,6 +704,11 @@ timer_thread_register_waiting(rb_thread_t *th, int fd, enum thread_sched_waiting
{
#if HAVE_SYS_EVENT_H
if (num_events > 0) {
if (kqueue_already_registered(fd)) {
rb_native_mutex_unlock(&timer_th.waiting_lock);
return false;
}

if (kevent(timer_th.event_fd, ke, num_events, NULL, 0, NULL) == -1) {
RUBY_DEBUG_LOG("failed (%d)", errno);

Expand Down

0 comments on commit 8201549

Please sign in to comment.