Project

General

Profile

Backport #5700 ยป bug5700.patch

nagachika (Tomoyuki Chikanaga), 02/10/2012 12:30 PM

View differences:

cont.c
330 330
    return size;
331 331
}
332 332

  
333
VALUE
334
rb_obj_is_fiber(VALUE obj)
335
{
336
    if (rb_typeddata_is_kind_of(obj, &fiber_data_type)) {
337
	return Qtrue;
338
    }
339
    else {
340
	return Qfalse;
341
    }
342
}
343

  
333 344
static void
334 345
cont_save_machine_stack(rb_thread_t *th, rb_context_t *cont)
335 346
{
......
1347 1358
    return rb_fiber_transfer(return_fiber(), argc, argv);
1348 1359
}
1349 1360

  
1361
void
1362
rb_fiber_reset_root_local_storage(VALUE thval)
1363
{
1364
    rb_thread_t *th;
1365
    rb_fiber_t	*fib;
1366

  
1367
    GetThreadPtr(thval, th);
1368
    if (th->root_fiber && th->root_fiber != th->fiber) {
1369
	GetFiberPtr(th->root_fiber, fib);
1370
	th->local_storage = fib->cont.saved_thread.local_storage;
1371
    }
1372
}
1373

  
1350 1374
/*
1351 1375
 *  call-seq:
1352 1376
 *     fiber.alive? -> true or false
gc.c
3248 3248
	while (p < pend) {
3249 3249
	    if (BUILTIN_TYPE(p) == T_DATA &&
3250 3250
		DATA_PTR(p) && RANY(p)->as.data.dfree &&
3251
		!rb_obj_is_thread((VALUE)p) && !rb_obj_is_mutex((VALUE)p) ) {
3251
		!rb_obj_is_thread((VALUE)p) && !rb_obj_is_mutex((VALUE)p) &&
3252
		!rb_obj_is_fiber((VALUE)p)) {
3252 3253
		p->as.free.flags = 0;
3253 3254
		if (RTYPEDDATA_P(p)) {
3254 3255
		    RDATA(p)->dfree = RANY(p)->as.typeddata.type->function.dfree;
internal.h
62 62
int rb_parse_in_main(void);
63 63
VALUE rb_insns_name_array(void);
64 64

  
65
/* cont.c */
66
VALUE rb_obj_is_fiber(VALUE);
67
void rb_fiber_reset_root_local_storage(VALUE);
68

  
65 69
/* debug.c */
66 70
PRINTF_ARGS(void ruby_debug_printf(const char*, ...), 1, 2);
67 71

  
vm.c
1611 1611
	rb_gc_force_recycle(vm->self);
1612 1612
	vm->main_thread = 0;
1613 1613
	if (th) {
1614
	    rb_fiber_reset_root_local_storage(th->self);
1614 1615
	    thread_free(th);
1615 1616
	}
1616 1617
	if (vm->living_threads) {