mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
Merge 0bcf056e7f
into a04555c8ab
This commit is contained in:
commit
965c664881
2 changed files with 27 additions and 13 deletions
|
@ -3166,20 +3166,26 @@ rb_thread_create_timer_thread(void)
|
|||
timer_thread_setup_mn();
|
||||
}
|
||||
|
||||
pthread_create(&timer_th.pthread_id, NULL, timer_thread_func, GET_VM());
|
||||
if (pthread_create(&timer_th.pthread_id, NULL, timer_thread_func, GET_VM()) != 0) {
|
||||
system_working = 0;
|
||||
// NOTE: safe to call into VM here even if we're in the middle of a call to `rb_fork_ruby()`
|
||||
rb_warn("Couldn't create timer thread, error: %s", strerror(errno));
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
native_stop_timer_thread(void)
|
||||
{
|
||||
RUBY_ATOMIC_SET(system_working, 0);
|
||||
if (RUBY_ATOMIC_LOAD(system_working)) {
|
||||
RUBY_ATOMIC_SET(system_working, 0);
|
||||
|
||||
RUBY_DEBUG_LOG("wakeup send %d", timer_th.comm_fds[1]);
|
||||
timer_thread_wakeup_force();
|
||||
RUBY_DEBUG_LOG("wakeup sent");
|
||||
pthread_join(timer_th.pthread_id, NULL);
|
||||
RUBY_DEBUG_LOG("wakeup send %d", timer_th.comm_fds[1]);
|
||||
timer_thread_wakeup_force();
|
||||
RUBY_DEBUG_LOG("wakeup sent");
|
||||
pthread_join(timer_th.pthread_id, NULL);
|
||||
|
||||
if (TT_DEBUG) fprintf(stderr, "stop timer thread\n");
|
||||
if (TT_DEBUG) fprintf(stderr, "stop timer thread\n");
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -797,19 +797,27 @@ rb_thread_create_timer_thread(void)
|
|||
}
|
||||
timer_thread.id = w32_create_thread(1024 + (USE_RUBY_DEBUG_LOG ? BUFSIZ : 0),
|
||||
timer_thread_func, 0);
|
||||
w32_resume_thread(timer_thread.id);
|
||||
if (timer_thread.id == 0) {
|
||||
system_working = 0;
|
||||
rb_warn("Couldn't create timer thread, error:%s", strerror(thread_errno));
|
||||
}
|
||||
else {
|
||||
w32_resume_thread(timer_thread.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
native_stop_timer_thread(void)
|
||||
{
|
||||
RUBY_ATOMIC_SET(system_working, 0);
|
||||
if (RUBY_ATOMIC_LOAD(system_working)) {
|
||||
RUBY_ATOMIC_SET(system_working, 0);
|
||||
|
||||
SetEvent(timer_thread.lock);
|
||||
native_thread_join(timer_thread.id);
|
||||
CloseHandle(timer_thread.lock);
|
||||
timer_thread.lock = 0;
|
||||
SetEvent(timer_thread.lock);
|
||||
native_thread_join(timer_thread.id);
|
||||
CloseHandle(timer_thread.lock);
|
||||
timer_thread.lock = 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue