* cont.c (fiber_free): don't free unallocated local_storage. see #1325.

* cont.c (cont_init): clear local_storage not to use current thread's.

* cont.c (fiber_t_alloc, root_fiber_alloc): link itself always for
  a case that fiber_link_remove() is called before fiber_link_join().

* cont.c (fiber_init): don't join half-baked fiber.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25623 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
wanabe 2009-11-01 23:27:12 +00:00
Родитель 74d16cd0a4
Коммит b23461b5dc
2 изменённых файлов: 17 добавлений и 4 удалений

Просмотреть файл

@ -1,3 +1,14 @@
Mon Nov 2 08:17:31 2009 wanabe <s.wanabe@gmail.com>
* cont.c (fiber_free): don't free unallocated local_storage. see #1325.
* cont.c (cont_init): clear local_storage not to use current thread's.
* cont.c (fiber_t_alloc, root_fiber_alloc): link itself always for
a case that fiber_link_remove() is called before fiber_link_join().
* cont.c (fiber_init): don't join half-baked fiber.
Sun Nov 1 20:16:03 2009 NARUSE, Yui <naruse@ruby-lang.org> Sun Nov 1 20:16:03 2009 NARUSE, Yui <naruse@ruby-lang.org>
* ext/bigdecimal/bigdecimal.c: fixed rdoc. [ruby-core:26457] * ext/bigdecimal/bigdecimal.c: fixed rdoc. [ruby-core:26457]

10
cont.c
Просмотреть файл

@ -198,7 +198,8 @@ fiber_free(void *ptr)
if (ptr) { if (ptr) {
rb_fiber_t *fib = ptr; rb_fiber_t *fib = ptr;
if (fib->cont.type != ROOT_FIBER_CONTEXT) { if (fib->cont.type != ROOT_FIBER_CONTEXT &&
fib->cont.saved_thread.local_storage) {
st_free_table(fib->cont.saved_thread.local_storage); st_free_table(fib->cont.saved_thread.local_storage);
} }
fiber_link_remove(fib); fiber_link_remove(fib);
@ -283,6 +284,7 @@ cont_init(rb_context_t *cont, rb_thread_t *th)
{ {
/* save thread context */ /* save thread context */
cont->saved_thread = *th; cont->saved_thread = *th;
cont->saved_thread.local_storage = 0;
} }
static rb_context_t * static rb_context_t *
@ -731,6 +733,7 @@ fiber_t_alloc(VALUE fibval)
cont_init(&fib->cont, th); cont_init(&fib->cont, th);
fib->prev = Qnil; fib->prev = Qnil;
fib->status = CREATED; fib->status = CREATED;
fib->prev_fiber = fib->next_fiber = fib;
DATA_PTR(fibval) = fib; DATA_PTR(fibval) = fib;
@ -744,8 +747,6 @@ fiber_init(VALUE fibval, VALUE proc)
rb_context_t *cont = &fib->cont; rb_context_t *cont = &fib->cont;
rb_thread_t *th = &cont->saved_thread; rb_thread_t *th = &cont->saved_thread;
fiber_link_join(fib);
/* initialize cont */ /* initialize cont */
cont->vm_stack = 0; cont->vm_stack = 0;
@ -753,6 +754,8 @@ fiber_init(VALUE fibval, VALUE proc)
th->stack_size = FIBER_VM_STACK_SIZE; th->stack_size = FIBER_VM_STACK_SIZE;
th->stack = ALLOC_N(VALUE, th->stack_size); th->stack = ALLOC_N(VALUE, th->stack_size);
fiber_link_join(fib);
th->cfp = (void *)(th->stack + th->stack_size); th->cfp = (void *)(th->stack + th->stack_size);
th->cfp--; th->cfp--;
th->cfp->pc = 0; th->cfp->pc = 0;
@ -875,7 +878,6 @@ root_fiber_alloc(rb_thread_t *th)
/* no need to allocate vm stack */ /* no need to allocate vm stack */
fib = fiber_t_alloc(fiber_alloc(rb_cFiber)); fib = fiber_t_alloc(fiber_alloc(rb_cFiber));
fib->cont.type = ROOT_FIBER_CONTEXT; fib->cont.type = ROOT_FIBER_CONTEXT;
fib->prev_fiber = fib->next_fiber = fib;
return fib; return fib;
} }