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