summaryrefslogtreecommitdiffstats
path: root/cont.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-05-29 01:59:53 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-05-29 01:59:53 +0000
commitc55e7d2abc2f94c2ebf6cf119d826ea7a3fe9048 (patch)
tree47fc8916b5816c5f32544f09d30295381a2bc3a2 /cont.c
parent1fe0a3655fc1715540fda45e2e92679b02e925d0 (diff)
downloadruby-c55e7d2abc2f94c2ebf6cf119d826ea7a3fe9048.tar.gz
ruby-c55e7d2abc2f94c2ebf6cf119d826ea7a3fe9048.tar.xz
ruby-c55e7d2abc2f94c2ebf6cf119d826ea7a3fe9048.zip
* cont.c: fix bug around Continuation and Fiber.
* test/ruby/test_continuation.rb: add tests for Continuation. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@12401 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'cont.c')
-rw-r--r--cont.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/cont.c b/cont.c
index 4f228f03b..786f00835 100644
--- a/cont.c
+++ b/cont.c
@@ -53,7 +53,7 @@ cont_mark(void *ptr)
rb_gc_mark_locations(cont->vm_stack,
cont->vm_stack + cont->saved_thread.stack_size);
}
-
+
if (cont->machine_stack) {
rb_gc_mark_locations(cont->machine_stack,
cont->machine_stack + cont->machine_stack_size);
@@ -128,6 +128,7 @@ cont_capture(volatile int *stat)
cont->vm_stack = ALLOC_N(VALUE, th->stack_size);
MEMCPY(cont->vm_stack, th->stack, VALUE, th->stack_size);
+ th->stack = 0;
cont_save_machine_stack(th, cont);
@@ -157,10 +158,12 @@ cont_restore_1(rb_context_t *cont)
/* fiber */
th->stack = sth->stack;
th->stack_size = sth->stack_size;
+ th->fiber = cont->self;
}
else {
/* continuation */
MEMCPY(th->stack, cont->vm_stack, VALUE, sth->stack_size);
+ th->fiber = sth->fiber;
}
th->cfp = sth->cfp;
@@ -169,11 +172,10 @@ cont_restore_1(rb_context_t *cont)
th->state = sth->state;
th->status = sth->status;
th->tag = sth->tag;
+ th->trap_tag = sth->trap_tag;
th->errinfo = sth->errinfo;
th->first_proc = sth->first_proc;
- th->fiber = cont->self;
-
/* restore machine stack */
if (cont->machine_stack_src) {
MEMCPY(cont->machine_stack_src, cont->machine_stack,