summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-12-29 15:00:15 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-12-29 15:00:15 +0000
commitdbbc1821db4919a0ca87824c13a7f7fe476797c3 (patch)
treeb40d909e049efadc30adbde39b6d62abc65f8b0c
parent6bcfa40b19a6b2f61772a34e33878b09afa3699e (diff)
downloadruby-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--ChangeLog8
-rw-r--r--eval.c36
-rw-r--r--gc.c2
3 files changed, 46 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index d6254c178..f0c37b0e9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
diff --git a/eval.c b/eval.c
index 40599b589..9cdd3631f 100644
--- a/eval.c
+++ b/eval.c
@@ -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
diff --git a/gc.c b/gc.c
index 7c8324cf6..e64499262 100644
--- a/gc.c
+++ b/gc.c
@@ -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;