diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-04-10 17:34:29 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-04-10 17:34:29 +0000 |
commit | a677da209b16f43198b3485dda89dce862fb9bfb (patch) | |
tree | e259f7095e3192c98fc2d69ad4091361fce86670 /activerecord/lib | |
parent | 1ee780b3bb0037cb4c9a0dd5288a4ae92dcf54c3 (diff) | |
download | rails-a677da209b16f43198b3485dda89dce862fb9bfb.tar.gz rails-a677da209b16f43198b3485dda89dce862fb9bfb.tar.bz2 rails-a677da209b16f43198b3485dda89dce862fb9bfb.zip |
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
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/transactions.rb | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/transactions.rb b/activerecord/lib/active_record/transactions.rb index d6b99008ee..de2937a96d 100644 --- a/activerecord/lib/active_record/transactions.rb +++ b/activerecord/lib/active_record/transactions.rb @@ -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 @@ module ActiveRecord # 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 @@ module ActiveRecord raise ensure unlock_mutex + trap('TERM', previous_handler) end end |