ruby-changes:9585
From: yugui <ko1@a...>
Date: Sun, 28 Dec 2008 18:42:19 +0900 (JST)
Subject: [ruby-changes:9585] Ruby:r21125 (ruby_1_9_1): merges r21096 from trunk into ruby_1_9_1.
yugui 2008-12-28 18:41:53 +0900 (Sun, 28 Dec 2008) New Revision: 21125 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=21125 Log: merges r21096 from trunk into ruby_1_9_1. * thread.c (rb_thread_atfork, rb_thread_atfork_before_exec): DRY. Modified files: branches/ruby_1_9_1/ChangeLog branches/ruby_1_9_1/thread.c Index: ruby_1_9_1/ChangeLog =================================================================== --- ruby_1_9_1/ChangeLog (revision 21124) +++ ruby_1_9_1/ChangeLog (revision 21125) @@ -1,3 +1,7 @@ +Sat Dec 27 19:30:01 2008 Nobuyoshi Nakada <nobu@r...> + + * thread.c (rb_thread_atfork, rb_thread_atfork_before_exec): DRY. + Sat Dec 27 17:08:43 2008 Nobuyoshi Nakada <nobu@r...> * .gdbinit (dummy_gdb_enums.special_consts): forces to load debug Index: ruby_1_9_1/thread.c =================================================================== --- ruby_1_9_1/thread.c (revision 21124) +++ ruby_1_9_1/thread.c (revision 21125) @@ -2438,14 +2438,29 @@ } } +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 -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; rb_thread_t *th; GetThreadPtr(thval, th); - if (th != current_th) { + if (th != (rb_thread_t *)current_th) { thread_cleanup_func(th); } return ST_CONTINUE; @@ -2454,27 +2469,18 @@ void rb_thread_atfork(void) { - 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, 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_thread_atfork_internal(terminate_atfork_i); rb_reset_random_seed(); } 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; rb_thread_t *th; GetThreadPtr(thval, th); - if (th != current_th) { + if (th != (rb_thread_t *)current_th) { thread_cleanup_func_before_exec(th); } return ST_CONTINUE; @@ -2483,16 +2489,7 @@ void rb_thread_atfork_before_exec(void) { - 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, 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(); + rb_thread_atfork_internal(terminate_atfork_before_exec_i); } struct thgroup { -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/