You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by cm...@apache.org on 2010/11/12 21:35:08 UTC

svn commit: r1034557 - /subversion/trunk/subversion/bindings/swig/ruby/svn/fs.rb

Author: cmpilato
Date: Fri Nov 12 20:35:07 2010
New Revision: 1034557

URL: http://svn.apache.org/viewvc?rev=1034557&view=rev
Log:
Fix (ahem... I guess) issue #3512 ("ruby bindings: too many open files
error") by ensuring that opened file handles get closed.

* subversion/bindings/swig/ruby/svn/fs.rb
  (FileDiff::files): Ensure that the tempfiles we open are closed.
  (FileDiff::dump_contents): Don't (re-)open or close tempfiles; in
    fact, rename 'tempfile' parameter to 'open_tempfile' just to make it
    clear that the file is already open.

Modified:
    subversion/trunk/subversion/bindings/swig/ruby/svn/fs.rb

Modified: subversion/trunk/subversion/bindings/swig/ruby/svn/fs.rb
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/swig/ruby/svn/fs.rb?rev=1034557&r1=1034556&r2=1034557&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/swig/ruby/svn/fs.rb (original)
+++ subversion/trunk/subversion/bindings/swig/ruby/svn/fs.rb Fri Nov 12 20:35:07 2010
@@ -602,8 +602,13 @@ module Svn
           @tempfile1 = Tempfile.new("svn_fs")
           @tempfile2 = Tempfile.new("svn_fs")
 
-          dump_contents(@tempfile1, @root1, @path1)
-          dump_contents(@tempfile2, @root2, @path2)
+          begin
+            dump_contents(@tempfile1, @root1, @path1)
+            dump_contents(@tempfile2, @root2, @path2)
+          ensure
+            @tempfile1.close
+            @tempfile2.close
+          end
 
           [@tempfile1, @tempfile2]
         end
@@ -623,15 +628,10 @@ module Svn
       end
 
       private
-      def dump_contents(tempfile, root, path)
+      def dump_contents(open_tempfile, root, path)
         if root and path
-          begin
-            tempfile.open
-            root.file_contents(path) do |stream|
-              tempfile.print(stream.read)
-            end
-          ensure
-            tempfile.close
+          root.file_contents(path) do |stream|
+            open_tempfile.print(stream.read)
           end
         end
       end