ruby-changes:40430
From: normal <ko1@a...>
Date: Tue, 10 Nov 2015 06:18:56 +0900 (JST)
Subject: [ruby-changes:40430] normal:r52511 (trunk): variable.c (rb_autoload_load): allow recursive calls
normal 2015-11-10 06:18:42 +0900 (Tue, 10 Nov 2015) New Revision: 52511 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=52511 Log: variable.c (rb_autoload_load): allow recursive calls * variable.c (rb_autoload_load): allow recursive calls [ruby-core:71345] [Bug #11658] * test/ruby/test_autoload.rb (test_autoload_while_autoloading): new test by: Hiroshi Shirosaki <h.shirosaki@g...> [ruby-core:71390] Modified files: trunk/ChangeLog trunk/test/ruby/test_autoload.rb trunk/variable.c Index: ChangeLog =================================================================== --- ChangeLog (revision 52510) +++ ChangeLog (revision 52511) @@ -1,3 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Tue Nov 10 06:17:17 2015 Eric Wong <e@8...> + + * variable.c (rb_autoload_load): allow recursive calls + [ruby-core:71345] [Bug #11658] + * test/ruby/test_autoload.rb (test_autoload_while_autoloading): + new test by: Hiroshi Shirosaki <h.shirosaki@g...> + [ruby-core:71390] + Tue Nov 10 00:36:46 2015 Tanaka Akira <akr@f...> * lib/resolv.rb (Resolv::DNS::Message::MessageEncoder#put_labels): Index: variable.c =================================================================== --- variable.c (revision 52510) +++ variable.c (revision 52511) @@ -2179,6 +2179,9 @@ rb_autoload_load(VALUE mod, ID id) https://github.com/ruby/ruby/blob/trunk/variable.c#L2179 */ list_head_init(&state.waitq.head); } + else if (state.thread == ele->state->thread) { + return Qfalse; + } else { list_add_tail(&ele->state->waitq.head, &state.waitq.node); /* Index: test/ruby/test_autoload.rb =================================================================== --- test/ruby/test_autoload.rb (revision 52510) +++ test/ruby/test_autoload.rb (revision 52511) @@ -215,6 +215,25 @@ p Foo::Bar https://github.com/ruby/ruby/blob/trunk/test/ruby/test_autoload.rb#L215 end end + def test_autoload_while_autoloading + ruby_impl_require do |called_with| + Tempfile.create(%w(a .rb)) do |a| + Tempfile.create(%w(b .rb)) do |b| + a.puts "require '#{b.path}'; class AutoloadTest; end" + b.puts "class AutoloadTest; module B; end; end" + [a, b].each(&:flush) + add_autoload(a.path) + begin + assert(Object::AutoloadTest) + ensure + remove_autoload_constant + end + assert_equal [a.path, b.path], called_with + end + end + end + end + def add_autoload(path) (@autoload_paths ||= []) << path ::Object.class_eval {autoload(:AutoloadTest, path)} -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/