From 1fd502ccc1332c3766b04773370e2d5c4836ad2a Mon Sep 17 00:00:00 2001 From: matz Date: Wed, 14 Mar 2001 08:39:13 +0000 Subject: [PATCH] * eval.c (rb_thread_schedule): raise FATAL just once to THREAD_TO_KILL. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1252 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ eval.c | 14 ++++++++++---- lib/thread.rb | 2 +- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 889294473b..ed4341f813 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Wed Mar 14 16:41:45 2001 Yukihiro Matsumoto + + * eval.c (rb_thread_schedule): raise FATAL just once to + THREAD_TO_KILL. + Wed Mar 14 10:41:34 2001 Yukihiro Matsumoto * eval.c (rb_yield_0): 0 (= Qfalse) is a valid value, so that diff --git a/eval.c b/eval.c index 197f6a662b..5d2f0016fe 100644 --- a/eval.c +++ b/eval.c @@ -6881,7 +6881,9 @@ struct thread { VALUE thread; }; -#define THREAD_RAISED 0x200 +#define THREAD_RAISED 0x200 /* temporary flag */ +#define THREAD_TERMINATING 0x400 /* persistent flag */ +#define THREAD_FLAGS_MASK 0x400 /* mask for persistent flags */ #define FOREACH_THREAD_FROM(f,x) x = f; do { x = x->next; #define END_FOREACH_FROM(f,x) } while (x != f) @@ -7033,7 +7035,8 @@ rb_thread_save_context(th) th->wrapper = ruby_wrapper; th->dyna_vars = ruby_dyna_vars; th->block = ruby_block; - th->flags = scope_vmode | (rb_trap_immediate<<8); + th->flags &= THREAD_FLAGS_MASK; + th->flags |= (rb_trap_immediate<<8) | scope_vmode; th->iter = ruby_iter; th->tag = prot_tag; th->tracing = tracing; @@ -7459,8 +7462,11 @@ rb_thread_schedule() curr_thread = next; if (next->status == THREAD_TO_KILL) { - /* execute ensure-clause if any */ - rb_thread_restore_context(next, RESTORE_FATAL); + if (!(next->flags & THREAD_TERMINATING)) { + next->flags |= THREAD_TERMINATING; + /* terminate; execute ensure-clause if any */ + rb_thread_restore_context(next, RESTORE_FATAL); + } } rb_thread_restore_context(next, RESTORE_NORMAL); } diff --git a/lib/thread.rb b/lib/thread.rb index d4b6ad6ec1..559cd95a8a 100644 --- a/lib/thread.rb +++ b/lib/thread.rb @@ -185,7 +185,7 @@ class Queue end end def shift(non_block=false) - pop(non_block=false) + pop(non_block) end alias deq shift