summaryrefslogtreecommitdiff
path: root/thread_pthread.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-11-28 13:00:49 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-11-28 13:00:49 +0000
commite4cf9c59fda102a80aa767c3a66a4738e26f6213 (patch)
treecc881702491009174533e34ad0764c9ab6083720 /thread_pthread.c
parent7a4b99129b1e05221add4132533a92de4c454da3 (diff)
* thread_pthread.c: remove pthread_atfork().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29963 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'thread_pthread.c')
-rw-r--r--thread_pthread.c47
1 files changed, 12 insertions, 35 deletions
diff --git a/thread_pthread.c b/thread_pthread.c
index 054e7034dc..c5f04e4d9e 100644
--- a/thread_pthread.c
+++ b/thread_pthread.c
@@ -29,8 +29,6 @@ static void native_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex);
static void native_cond_initialize(pthread_cond_t *cond);
static void native_cond_destroy(pthread_cond_t *cond);
-static void native_atfork(void (*prepare)(void), void (*parent)(void), void (*child)(void));
-
#define native_mutex_reinitialize_atfork(lock) (\
native_mutex_unlock(lock), \
native_mutex_initialize(lock), \
@@ -125,39 +123,19 @@ gvl_release(rb_vm_t *vm)
}
static void
-gvl_atfork(rb_vm_t *vm)
-{
-#if GVL_SIMPLE_LOCK
- native_mutex_reinitialize_atfork(&vm->gvl.lock);
-#else
- /* do nothing */
-#endif
-}
-
-static void gvl_reinit(rb_vm_t *vm);
-
-static void
-gvl_atfork_child(void)
-{
- gvl_reinit(GET_VM());
-}
-
-static void
gvl_init(rb_vm_t *vm)
{
if (GVL_DEBUG) fprintf(stderr, "gvl init\n");
- native_atfork(0, 0, gvl_atfork_child);
- gvl_reinit(vm);
-}
-static void
-gvl_reinit(rb_vm_t *vm)
-{
+#if GVL_SIMPLE_LOCK
+ native_mutex_reinitialize_atfork(&vm->gvl.lock);
+#else
native_mutex_initialize(&vm->gvl.lock);
vm->gvl.waiting_threads = 0;
vm->gvl.waiting_last_thread = 0;
vm->gvl.waiting = 0;
vm->gvl.acquired = 0;
+#endif
}
static void
@@ -168,6 +146,14 @@ gvl_destroy(rb_vm_t *vm)
}
static void
+gvl_atfork(rb_vm_t *vm)
+{
+ if (GVL_DEBUG) fprintf(stderr, "gvl atfork\n");
+ gvl_init(vm);
+ gvl_acquire(vm, GET_THREAD());
+}
+
+static void
mutex_debug(const char *msg, pthread_mutex_t *lock)
{
if (0) {
@@ -293,15 +279,6 @@ native_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, struct times
return r;
}
-static void
-native_atfork(void (*prepare)(void), void (*parent)(void), void (*child)(void))
-{
- int r = pthread_atfork(prepare, parent, child);
- if (r != 0) {
- rb_bug_errno("native_atfork", r);
- }
-}
-
#define native_cleanup_push pthread_cleanup_push
#define native_cleanup_pop pthread_cleanup_pop
#ifdef HAVE_SCHED_YIELD