summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--thread.c1
-rw-r--r--thread_pthread.c15
-rw-r--r--thread_win32.c1
3 files changed, 10 insertions, 7 deletions
diff --git a/thread.c b/thread.c
index c756b53..51710d2 100644
--- a/thread.c
+++ b/thread.c
@@ -4396,6 +4396,7 @@ rb_thread_atfork_internal(rb_thread_t *th, void (*atfork)(rb_thread_t *, const r
vm->main_thread = th;
gvl_atfork(th->vm);
+ ubf_list_atfork();
list_for_each(&vm->living_threads, i, vmlt_node) {
atfork(i, th);
diff --git a/thread_pthread.c b/thread_pthread.c
index 2fd60dd..2923c15 100644
--- a/thread_pthread.c
+++ b/thread_pthread.c
@@ -532,10 +532,6 @@ native_cond_timeout(rb_nativethread_cond_t *cond, struct timespec timeout_rel)
#define native_cleanup_push pthread_cleanup_push
#define native_cleanup_pop pthread_cleanup_pop
-#if defined(USE_UBF_LIST)
-static rb_nativethread_lock_t ubf_list_lock;
-#endif
-
static pthread_key_t ruby_native_thread_key;
static void
@@ -574,9 +570,6 @@ Init_native_thread(rb_thread_t *th)
th->thread_id = pthread_self();
fill_thread_id_str(th);
native_thread_init(th);
-#ifdef USE_UBF_LIST
- rb_native_mutex_initialize(&ubf_list_lock);
-#endif
posix_signal(SIGVTALRM, null_func);
}
@@ -1268,6 +1261,14 @@ native_cond_sleep(rb_thread_t *th, struct timespec *timeout_rel)
#ifdef USE_UBF_LIST
static LIST_HEAD(ubf_list_head);
+static rb_nativethread_lock_t ubf_list_lock = RB_NATIVETHREAD_LOCK_INIT;
+
+static void
+ubf_list_atfork(void)
+{
+ list_head_init(&ubf_list_head);
+ rb_native_mutex_initialize(&ubf_list_lock);
+}
/* The thread 'th' is registered to be trying unblock. */
static void
diff --git a/thread_win32.c b/thread_win32.c
index 6e9f18f..af9d351 100644
--- a/thread_win32.c
+++ b/thread_win32.c
@@ -23,6 +23,7 @@
#define ubf_wakeup_all_threads() do {} while (0)
#define ubf_threads_empty() (1)
#define ubf_timer_disarm() do {} while (0)
+#define ubf_list_atfork() do {} while (0)
static volatile DWORD ruby_native_thread_key = TLS_OUT_OF_INDEXES;