mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
merge revision(s) 34629,34630:
* cont.c (rb_fiber_reset_root_local_storage): add a new function to restore rb_thread_t::local_storage. * cont.c (rb_obj_is_fiber): add a new function to tell finalizer to prevent fibers from destroy. * gc.c (rb_objspace_call_finalizer): don't sweep fibers at finalizing objspace. * internal.h (rb_fiber_reset_root_local_storage, rb_obj_is_fiber): add prototypes. * vm.c (ruby_vm_destruct): reset main thread's local_storage before free main thread. rb_thread_t::local_storage is replaced by fiber's local storage when forked from fiber, and it should be already freed when the fiber was destroyed. * test/ruby/test_fiber.rb (test_fork_from_fiber): add test for fork from fiber. when the fiber was destroyed. [ruby-core:41456] [Bug #5700] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@34637 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
a4debd6ae2
commit
8cdf5c4179
7 changed files with 70 additions and 2 deletions
22
ChangeLog
22
ChangeLog
|
@ -1,3 +1,25 @@
|
||||||
|
Thu Feb 16 07:34:34 2012 CHIKANAGA Tomoyuki <nagachika00@gmail.com>
|
||||||
|
|
||||||
|
* cont.c (rb_fiber_reset_root_local_storage): add a new function to
|
||||||
|
restore rb_thread_t::local_storage.
|
||||||
|
|
||||||
|
* cont.c (rb_obj_is_fiber): add a new function to tell finalizer to
|
||||||
|
prevent fibers from destroy.
|
||||||
|
|
||||||
|
* gc.c (rb_objspace_call_finalizer): don't sweep fibers at finalizing
|
||||||
|
objspace.
|
||||||
|
|
||||||
|
* internal.h (rb_fiber_reset_root_local_storage, rb_obj_is_fiber):
|
||||||
|
add prototypes.
|
||||||
|
|
||||||
|
* vm.c (ruby_vm_destruct): reset main thread's local_storage before
|
||||||
|
free main thread. rb_thread_t::local_storage is replaced by fiber's
|
||||||
|
local storage when forked from fiber, and it should be already freed
|
||||||
|
when the fiber was destroyed. [ruby-core:41456] [Bug #5700]
|
||||||
|
|
||||||
|
* test/ruby/test_fiber.rb (test_fork_from_fiber): add test for fork
|
||||||
|
from fiber.
|
||||||
|
|
||||||
Thu Feb 16 06:30:37 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Thu Feb 16 06:30:37 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* ext/fiddle/closure.c (callback): deal with unsinged integers.
|
* ext/fiddle/closure.c (callback): deal with unsinged integers.
|
||||||
|
|
24
cont.c
24
cont.c
|
@ -324,6 +324,17 @@ fiber_memsize(const void *ptr)
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VALUE
|
||||||
|
rb_obj_is_fiber(VALUE obj)
|
||||||
|
{
|
||||||
|
if (rb_typeddata_is_kind_of(obj, &fiber_data_type)) {
|
||||||
|
return Qtrue;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return Qfalse;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cont_save_machine_stack(rb_thread_t *th, rb_context_t *cont)
|
cont_save_machine_stack(rb_thread_t *th, rb_context_t *cont)
|
||||||
{
|
{
|
||||||
|
@ -1342,6 +1353,19 @@ rb_fiber_yield(int argc, VALUE *argv)
|
||||||
return rb_fiber_transfer(return_fiber(), argc, argv);
|
return rb_fiber_transfer(return_fiber(), argc, argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
rb_fiber_reset_root_local_storage(VALUE thval)
|
||||||
|
{
|
||||||
|
rb_thread_t *th;
|
||||||
|
rb_fiber_t *fib;
|
||||||
|
|
||||||
|
GetThreadPtr(thval, th);
|
||||||
|
if (th->root_fiber && th->root_fiber != th->fiber) {
|
||||||
|
GetFiberPtr(th->root_fiber, fib);
|
||||||
|
th->local_storage = fib->cont.saved_thread.local_storage;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* fiber.alive? -> true or false
|
* fiber.alive? -> true or false
|
||||||
|
|
3
gc.c
3
gc.c
|
@ -3057,7 +3057,8 @@ rb_objspace_call_finalizer(rb_objspace_t *objspace)
|
||||||
while (p < pend) {
|
while (p < pend) {
|
||||||
if (BUILTIN_TYPE(p) == T_DATA &&
|
if (BUILTIN_TYPE(p) == T_DATA &&
|
||||||
DATA_PTR(p) && RANY(p)->as.data.dfree &&
|
DATA_PTR(p) && RANY(p)->as.data.dfree &&
|
||||||
!rb_obj_is_thread((VALUE)p) && !rb_obj_is_mutex((VALUE)p) ) {
|
!rb_obj_is_thread((VALUE)p) && !rb_obj_is_mutex((VALUE)p) &&
|
||||||
|
!rb_obj_is_fiber((VALUE)p)) {
|
||||||
p->as.free.flags = 0;
|
p->as.free.flags = 0;
|
||||||
if (RTYPEDDATA_P(p)) {
|
if (RTYPEDDATA_P(p)) {
|
||||||
RDATA(p)->dfree = RANY(p)->as.typeddata.type->function.dfree;
|
RDATA(p)->dfree = RANY(p)->as.typeddata.type->function.dfree;
|
||||||
|
|
|
@ -61,6 +61,10 @@ int rb_parse_in_eval(void);
|
||||||
int rb_parse_in_main(void);
|
int rb_parse_in_main(void);
|
||||||
VALUE rb_insns_name_array(void);
|
VALUE rb_insns_name_array(void);
|
||||||
|
|
||||||
|
/* cont.c */
|
||||||
|
VALUE rb_obj_is_fiber(VALUE);
|
||||||
|
void rb_fiber_reset_root_local_storage(VALUE);
|
||||||
|
|
||||||
/* debug.c */
|
/* debug.c */
|
||||||
PRINTF_ARGS(void ruby_debug_printf(const char*, ...), 1, 2);
|
PRINTF_ARGS(void ruby_debug_printf(const char*, ...), 1, 2);
|
||||||
|
|
||||||
|
|
|
@ -220,5 +220,21 @@ class TestFiber < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
assert_equal("Can't call on top of Fiber or Thread", error.message, bug5083)
|
assert_equal("Can't call on top of Fiber or Thread", error.message, bug5083)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_fork_from_fiber
|
||||||
|
begin
|
||||||
|
Process.fork{}
|
||||||
|
rescue NotImplementedError
|
||||||
|
return
|
||||||
|
end
|
||||||
|
bug5700 = '[ruby-core:41456]'
|
||||||
|
pid = nil
|
||||||
|
assert_nothing_raised(bug5700) do
|
||||||
|
Fiber.new{ pid = fork {} }.resume
|
||||||
|
end
|
||||||
|
pid, status = Process.waitpid2(pid)
|
||||||
|
assert_equal(0, status.exitstatus, bug5700)
|
||||||
|
assert_equal(false, status.signaled?, bug5700)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#define RUBY_VERSION "1.9.3"
|
#define RUBY_VERSION "1.9.3"
|
||||||
#define RUBY_PATCHLEVEL 121
|
#define RUBY_PATCHLEVEL 122
|
||||||
|
|
||||||
#define RUBY_RELEASE_DATE "2012-02-16"
|
#define RUBY_RELEASE_DATE "2012-02-16"
|
||||||
#define RUBY_RELEASE_YEAR 2012
|
#define RUBY_RELEASE_YEAR 2012
|
||||||
|
|
1
vm.c
1
vm.c
|
@ -1609,6 +1609,7 @@ ruby_vm_destruct(rb_vm_t *vm)
|
||||||
rb_gc_force_recycle(vm->self);
|
rb_gc_force_recycle(vm->self);
|
||||||
vm->main_thread = 0;
|
vm->main_thread = 0;
|
||||||
if (th) {
|
if (th) {
|
||||||
|
rb_fiber_reset_root_local_storage(th->self);
|
||||||
thread_free(th);
|
thread_free(th);
|
||||||
}
|
}
|
||||||
if (vm->living_threads) {
|
if (vm->living_threads) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue