* thread.c (rb_thread_atfork, rb_thread_atfork_before_exec): DRY.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21096 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
10af217ff3
commit
b5d2750bbc
@ -1,3 +1,7 @@
|
|||||||
|
Sat Dec 27 19:30:01 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* thread.c (rb_thread_atfork, rb_thread_atfork_before_exec): DRY.
|
||||||
|
|
||||||
Sat Dec 27 18:25:09 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
|
Sat Dec 27 18:25:09 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
* vm_eval.c (rb_f_loop): return enumerator if no block given.
|
* vm_eval.c (rb_f_loop): return enumerator if no block given.
|
||||||
|
45
thread.c
45
thread.c
@ -2438,14 +2438,29 @@ clear_coverage(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
rb_thread_atfork_internal(int (*atfork)(st_data_t, st_data_t, st_data_t))
|
||||||
|
{
|
||||||
|
rb_thread_t *th = GET_THREAD();
|
||||||
|
rb_vm_t *vm = th->vm;
|
||||||
|
VALUE thval = th->self;
|
||||||
|
vm->main_thread = th;
|
||||||
|
|
||||||
|
st_foreach(vm->living_threads, atfork, (st_data_t)th);
|
||||||
|
st_clear(vm->living_threads);
|
||||||
|
st_insert(vm->living_threads, thval, (st_data_t)th->thread_id);
|
||||||
|
vm->sleeper = 0;
|
||||||
|
clear_coverage();
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
terminate_atfork_i(st_data_t key, st_data_t val, rb_thread_t *current_th)
|
terminate_atfork_i(st_data_t key, st_data_t val, st_data_t current_th)
|
||||||
{
|
{
|
||||||
VALUE thval = key;
|
VALUE thval = key;
|
||||||
rb_thread_t *th;
|
rb_thread_t *th;
|
||||||
GetThreadPtr(thval, th);
|
GetThreadPtr(thval, th);
|
||||||
|
|
||||||
if (th != current_th) {
|
if (th != (rb_thread_t *)current_th) {
|
||||||
thread_cleanup_func(th);
|
thread_cleanup_func(th);
|
||||||
}
|
}
|
||||||
return ST_CONTINUE;
|
return ST_CONTINUE;
|
||||||
@ -2454,27 +2469,18 @@ terminate_atfork_i(st_data_t key, st_data_t val, rb_thread_t *current_th)
|
|||||||
void
|
void
|
||||||
rb_thread_atfork(void)
|
rb_thread_atfork(void)
|
||||||
{
|
{
|
||||||
rb_thread_t *th = GET_THREAD();
|
rb_thread_atfork_internal(terminate_atfork_i);
|
||||||
rb_vm_t *vm = th->vm;
|
|
||||||
VALUE thval = th->self;
|
|
||||||
vm->main_thread = th;
|
|
||||||
|
|
||||||
st_foreach(vm->living_threads, terminate_atfork_i, (st_data_t)th);
|
|
||||||
st_clear(vm->living_threads);
|
|
||||||
st_insert(vm->living_threads, thval, (st_data_t) th->thread_id);
|
|
||||||
vm->sleeper = 0;
|
|
||||||
clear_coverage();
|
|
||||||
rb_reset_random_seed();
|
rb_reset_random_seed();
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
terminate_atfork_before_exec_i(st_data_t key, st_data_t val, rb_thread_t *current_th)
|
terminate_atfork_before_exec_i(st_data_t key, st_data_t val, st_data_t current_th)
|
||||||
{
|
{
|
||||||
VALUE thval = key;
|
VALUE thval = key;
|
||||||
rb_thread_t *th;
|
rb_thread_t *th;
|
||||||
GetThreadPtr(thval, th);
|
GetThreadPtr(thval, th);
|
||||||
|
|
||||||
if (th != current_th) {
|
if (th != (rb_thread_t *)current_th) {
|
||||||
thread_cleanup_func_before_exec(th);
|
thread_cleanup_func_before_exec(th);
|
||||||
}
|
}
|
||||||
return ST_CONTINUE;
|
return ST_CONTINUE;
|
||||||
@ -2483,16 +2489,7 @@ terminate_atfork_before_exec_i(st_data_t key, st_data_t val, rb_thread_t *curren
|
|||||||
void
|
void
|
||||||
rb_thread_atfork_before_exec(void)
|
rb_thread_atfork_before_exec(void)
|
||||||
{
|
{
|
||||||
rb_thread_t *th = GET_THREAD();
|
rb_thread_atfork_internal(terminate_atfork_before_exec_i);
|
||||||
rb_vm_t *vm = th->vm;
|
|
||||||
VALUE thval = th->self;
|
|
||||||
vm->main_thread = th;
|
|
||||||
|
|
||||||
st_foreach(vm->living_threads, terminate_atfork_before_exec_i, (st_data_t)th);
|
|
||||||
st_clear(vm->living_threads);
|
|
||||||
st_insert(vm->living_threads, thval, (st_data_t) th->thread_id);
|
|
||||||
vm->sleeper = 0;
|
|
||||||
clear_coverage();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct thgroup {
|
struct thgroup {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user