From 6ef956ab90315f63d103bed0c3a7d9d2c0028019 Mon Sep 17 00:00:00 2001 From: sorah Date: Sun, 13 Mar 2011 07:14:07 +0000 Subject: [PATCH] * lib/pstore.rb: Fix don't raise "nested transaction" when thread_safe is true. Patch by Masaki Matsushita (Glass_saga). [ruby-dev:43337] * test/test_pstore.rb: Test for above. Patch by Masaki Matsushita (Glass_saga) [ruby-dev:43337] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31101 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 8 ++++++++ lib/pstore.rb | 2 ++ test/test_pstore.rb | 10 ++++++++++ 3 files changed, 20 insertions(+) diff --git a/ChangeLog b/ChangeLog index a333bd9336..0ce786a569 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Sun Mar 13 16:07:58 2011 Shota Fukumori + + * lib/pstore.rb: Fix don't raise "nested transaction" when thread_safe + is true. Patch by Masaki Matsushita (Glass_saga). [ruby-dev:43337] + + * test/test_pstore.rb: Test for above. + Patch by Masaki Matsushita (Glass_saga) [ruby-dev:43337] + Sat Mar 12 04:12:41 2011 Tanaka Akira * ext/openssl/ossl_ssl_session.c: parenthesize macro arguments. diff --git a/lib/pstore.rb b/lib/pstore.rb index 3114eb567f..9fb0249f3c 100644 --- a/lib/pstore.rb +++ b/lib/pstore.rb @@ -341,6 +341,8 @@ class PStore end end value + rescue ThreadError + raise PStore::Error, "nested transaction" end private diff --git a/test/test_pstore.rb b/test/test_pstore.rb index 32d79ea2ba..b6f79251da 100644 --- a/test/test_pstore.rb +++ b/test/test_pstore.rb @@ -100,4 +100,14 @@ class PStoreTest < Test::Unit::TestCase File.unlink("pstore.tmp2.#{Process.pid}") rescue nil end end + + def test_nested_transaction_raises_error + assert_raise(PStore::Error) do + @pstore.transaction { @pstore.transaction { } } + end + pstore = PStore.new("pstore.tmp2.#{Process.pid}", true) + assert_raise(PStore::Error) do + pstore.transaction { pstore.transaction { } } + end + end end