diff options
Diffstat (limited to 'thread.c')
-rw-r--r-- | thread.c | 27 |
1 files changed, 27 insertions, 0 deletions
@@ -2100,6 +2100,31 @@ rb_thread_start_timer_thread(void) } static int +clear_coverage_i(st_data_t key, st_data_t val, st_data_t dummy) +{ + int i; + VALUE lines = (VALUE)val; + + for (i = 0; i < RARRAY_LEN(lines); i++) { + if (RARRAY_PTR(lines)[i] != Qnil) { + RARRAY_PTR(lines)[i] = INT2FIX(0); + } + } + return ST_CONTINUE; +} + +static void +clear_coverage(void) +{ + if (rb_const_defined_at(rb_cObject, rb_intern("COVERAGE__"))) { + VALUE hash = rb_const_get_at(rb_cObject, rb_intern("COVERAGE__")); + if (TYPE(hash) == T_HASH) { + st_foreach(RHASH_TBL(hash), clear_coverage_i, 0); + } + } +} + +static int terminate_atfork_i(st_data_t key, st_data_t val, rb_thread_t *current_th) { VALUE thval = key; @@ -2124,6 +2149,7 @@ rb_thread_atfork(void) 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(); } @@ -2152,6 +2178,7 @@ rb_thread_atfork_before_exec(void) st_clear(vm->living_threads); st_insert(vm->living_threads, thval, (st_data_t) th->thread_id); vm->sleeper = 0; + clear_coverage(); } struct thgroup { |