From d6152dd51c833bae79208ee8c03bd6a1d21fe632 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Wed, 23 Aug 2017 22:03:18 -0700 Subject: Move parse frame array to the Map object This makes the frame stack per-parser, and per-thread. Fixes #3250 --- ruby/tests/basic.rb | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'ruby/tests') diff --git a/ruby/tests/basic.rb b/ruby/tests/basic.rb index 020effb0..94071ca0 100644 --- a/ruby/tests/basic.rb +++ b/ruby/tests/basic.rb @@ -96,8 +96,18 @@ module BasicTest optional :d, :enum, 4, "TestEnum" end end + + add_message "repro.Outer" do + map :items, :int32, :message, 1, "repro.Inner" + end + + add_message "repro.Inner" do + end end + + Outer = pool.lookup("repro.Outer").msgclass + Inner = pool.lookup("repro.Inner").msgclass Foo = pool.lookup("Foo").msgclass Bar = pool.lookup("Bar").msgclass Baz = pool.lookup("Baz").msgclass @@ -675,6 +685,21 @@ module BasicTest m.map_string_int32['aaa'] = 3 end + def test_concurrent_decoding + o = Outer.new + o.items[0] = Inner.new + raw = Outer.encode(o) + + thds = 2.times.map do + Thread.new do + 100000.times do + assert_equal o, Outer.decode(raw) + end + end + end + thds.map(&:join) + end + def test_map_encode_decode m = MapMessage.new( :map_string_int32 => {"a" => 1, "b" => 2}, -- cgit v1.2.3