mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* thread_pthread.c: remove pthread_atfork().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29963 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
7a4b99129b
commit
e4cf9c59fd
2 changed files with 16 additions and 35 deletions
|
@ -1,3 +1,7 @@
|
|||
Mon Nov 29 05:58:58 2010 Koichi Sasada <ko1@atdot.net>
|
||||
|
||||
* thread_pthread.c: remove pthread_atfork().
|
||||
|
||||
Mon Nov 29 05:54:22 2010 Koichi Sasada <ko1@atdot.net>
|
||||
|
||||
* thread_pthread.c (native_cond_*): Check return code.
|
||||
|
|
|
@ -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), \
|
||||
|
@ -124,40 +122,20 @@ gvl_release(rb_vm_t *vm)
|
|||
#endif
|
||||
}
|
||||
|
||||
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
|
||||
|
@ -167,6 +145,14 @@ gvl_destroy(rb_vm_t *vm)
|
|||
native_mutex_destroy(&vm->gvl.lock);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue