]> git.cworth.org Git - sup/commitdiff
slight betterification of Recoverable
authorwmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Fri, 23 Nov 2007 22:22:10 +0000 (22:22 +0000)
committerwmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Fri, 23 Nov 2007 22:22:10 +0000 (22:22 +0000)
git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@709 5c8cc53c-5e98-4d25-b20a-d8db53a31250

lib/sup/util.rb

index 6c8673c2fc56a64ab6f68077f8e6d07a25cd83d3..a402ed86382c8dfedc23060de64cf477eacabf0f 100644 (file)
@@ -501,13 +501,16 @@ class Recoverable
   def initialize o
     @o = o
     @e = nil
+    @mutex = Mutex.new
   end
 
   def clear_error!; @e = nil; end
   def has_errors?; !@e.nil?; end
   def error; @e; end
 
-  def method_missing m, *a, &b; __pass m, *a, &b; end
+  def method_missing m, *a, &b
+    @mutex.synchronize { __pass m, *a, &b }
+  end
   
   def id; __pass :id; end
   def to_s; __pass :to_s; end
@@ -520,7 +523,7 @@ class Recoverable
     begin
       @o.send(m, *a, &b)
     rescue Exception => e
-      @e = e
+      @e ||= e
       raise e
     end
   end