Added rollbacks of transactions if they're active as the dispatcher is killed...

Added rollbacks of transactions if they're active as the dispatcher is killed gracefully (TERM signal) #1054 [Leon Bredt]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1136 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
上级 1ee780b3
*SVN*
* Added rollbacks of transactions if they're active as the dispatcher is killed gracefully (TERM signal) #1054 [Leon Bredt]
* Added quoting of column names for fixtures #997 [jcfischer@gmail.com]
* Fixed counter_sql when no records exist in database for PostgreSQL (would give error, not 0) #1039 [Caleb Tennis]
......
......@@ -6,6 +6,9 @@ module ActiveRecord
module Transactions # :nodoc:
TRANSACTION_MUTEX = Mutex.new
class TransactionError < ActiveRecordError # :nodoc:
end
def self.append_features(base)
super
base.extend(ClassMethods)
......@@ -78,6 +81,9 @@ def self.append_features(base)
# Tribute: Object-level transactions are implemented by Transaction::Simple by Austin Ziegler.
module ClassMethods
def transaction(*objects, &block)
previous_handler = trap('TERM') do
raise TransactionError, "Transaction aborted"
end
lock_mutex
begin
......@@ -93,6 +99,7 @@ def transaction(*objects, &block)
raise
ensure
unlock_mutex
trap('TERM', previous_handler)
end
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册