diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-12-29 15:00:15 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-12-29 15:00:15 +0000 |
commit | dbbc1821db4919a0ca87824c13a7f7fe476797c3 (patch) | |
tree | b40d909e049efadc30adbde39b6d62abc65f8b0c | |
parent | 6bcfa40b19a6b2f61772a34e33878b09afa3699e (diff) | |
download | ruby-dbbc1821db4919a0ca87824c13a7f7fe476797c3.tar.gz ruby-dbbc1821db4919a0ca87824c13a7f7fe476797c3.tar.xz ruby-dbbc1821db4919a0ca87824c13a7f7fe476797c3.zip |
* eval.c (rb_gc_mark_threads): leave unmarked threads which won't wake
up alone, and mark threads in the loading table. [ruby-dev:28154]
* eval.c (rb_gc_abort_threads), gc.c (gc_sweep): kill unmarked
threads. [ruby-dev:28172]
git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8@9760 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | eval.c | 36 | ||||
-rw-r--r-- | gc.c | 2 |
3 files changed, 46 insertions, 0 deletions
@@ -1,3 +1,11 @@ +Thu Dec 29 23:59:37 2005 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * eval.c (rb_gc_mark_threads): leave unmarked threads which won't wake + up alone, and mark threads in the loading table. [ruby-dev:28154] + + * eval.c (rb_gc_abort_threads), gc.c (gc_sweep): kill unmarked + threads. [ruby-dev:28172] + Thu Dec 29 17:02:07 2005 Tanaka Akira <akr@m17n.org> * test/ruby/envutil.rb (EnvUtil.rubybin): search "ruby" instead of @@ -9974,6 +9974,16 @@ thread_mark(th) } } +static int +mark_loading_thread(key, value, lev) + ID key; + VALUE value; + int lev; +{ + rb_gc_mark(((rb_thread_t)value)->thread); + return ST_CONTINUE; +} + void rb_gc_mark_threads() { @@ -9983,9 +9993,35 @@ rb_gc_mark_threads() rb_gc_mark((VALUE)ruby_cref); if (!curr_thread) return; + rb_gc_mark(main_thread->thread); + rb_gc_mark(curr_thread->thread); FOREACH_THREAD_FROM(main_thread, th) { + switch (th->status) { + case THREAD_TO_KILL: + case THREAD_RUNNABLE: + break; + case THREAD_STOPPED: + if (th->wait_for) break; + default: + continue; + } rb_gc_mark(th->thread); } END_FOREACH_FROM(main_thread, th); + if (loading_tbl) st_foreach(loading_tbl, mark_loading_thread, 0); +} + +void +rb_gc_abort_threads() +{ + rb_thread_t th; + + FOREACH_THREAD_FROM(main_thread, th) { + if (FL_TEST(th->thread, FL_MARK)) continue; + if (th->status == THREAD_STOPPED) { + th->status = THREAD_TO_KILL; + rb_gc_mark(th->thread); + } + } END_FOREACH_FROM(main_thread, th); } static void @@ -1057,6 +1057,8 @@ gc_sweep() st_foreach(source_filenames, sweep_source_filename, 0); } + rb_gc_abort_threads(); + freelist = 0; final_list = deferred_final_list; deferred_final_list = 0; |