ruby-changes:17559
From: yugui <ko1@a...>
Date: Sat, 23 Oct 2010 18:37:15 +0900 (JST)
Subject: [ruby-changes:17559] Ruby:r29564 (ruby_1_9_2): merges r29415 from trunk into ruby_1_9_2. fixes #3910 #3951 and #3959.
yugui 2010-10-23 18:36:52 +0900 (Sat, 23 Oct 2010) New Revision: 29564 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=29564 Log: merges r29415 from trunk into ruby_1_9_2. fixes #3910 #3951 and #3959. -- * io.c (fptr_finalize): write_mutex might have been destroyed already in finalization phase, as the order of finalizers is not guaranteed. rb_mutex_t should be used in place of Mutex object in the future. Modified files: branches/ruby_1_9_2/ChangeLog branches/ruby_1_9_2/io.c branches/ruby_1_9_2/test/ruby/test_io.rb branches/ruby_1_9_2/version.h Index: ruby_1_9_2/ChangeLog =================================================================== --- ruby_1_9_2/ChangeLog (revision 29563) +++ ruby_1_9_2/ChangeLog (revision 29564) @@ -1,3 +1,10 @@ +Wed Oct 6 11:52:12 2010 Nobuyoshi Nakada <nobu@r...> + + * io.c (fptr_finalize): write_mutex might have been destroyed + already in finalization phase, as the order of finalizers is not + guaranteed. rb_mutex_t should be used in place of Mutex object + in the future. + Sun Sep 19 13:44:24 2010 Nobuyoshi Nakada <nobu@r...> * configure.in (LIBRUBY_SO): fix an oversight of replace Index: ruby_1_9_2/io.c =================================================================== --- ruby_1_9_2/io.c (revision 29563) +++ ruby_1_9_2/io.c (revision 29564) @@ -3423,7 +3423,7 @@ { VALUE err = Qnil; if (fptr->writeconv) { - if (fptr->write_lock) { + if (fptr->write_lock && !noraise) { struct finish_writeconv_arg arg; arg.fptr = fptr; arg.noalloc = noraise; @@ -3434,8 +3434,14 @@ } } if (fptr->wbuf_len) { - if (io_fflush(fptr) < 0 && NIL_P(err)) - err = noraise ? Qtrue : INT2NUM(errno); + if (noraise) { + if ((int)io_flush_buffer_sync(fptr) < 0 && NIL_P(err)) + err = Qtrue; + } + else { + if (io_fflush(fptr) < 0 && NIL_P(err)) + err = INT2NUM(errno); + } } if (IS_PREP_STDIO(fptr) || fptr->fd <= 2) { goto skip_fd_close; Index: ruby_1_9_2/version.h =================================================================== --- ruby_1_9_2/version.h (revision 29563) +++ ruby_1_9_2/version.h (revision 29564) @@ -1,5 +1,5 @@ #define RUBY_VERSION "1.9.2" -#define RUBY_PATCHLEVEL 17 +#define RUBY_PATCHLEVEL 18 #define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MINOR 9 #define RUBY_VERSION_TEENY 1 Index: ruby_1_9_2/test/ruby/test_io.rb =================================================================== --- ruby_1_9_2/test/ruby/test_io.rb (revision 29563) +++ ruby_1_9_2/test/ruby/test_io.rb (revision 29564) @@ -1623,4 +1623,33 @@ end end.each {|th| th.join} end + + def test_flush_in_finalizer1 + require 'tempfile' + bug3910 = '[ruby-dev:42341]' + path = Tempfile.new("bug3910").path + fds = [] + assert_nothing_raised(TypeError, bug3910) do + 500.times { + f = File.open(path, "w") + fds << f.fileno + f.print "hoge" + } + end + ensure + fds.each {|fd| IO.for_fd(fd).close rescue next} + end + + def test_flush_in_finalizer2 + require 'tempfile' + bug3910 = '[ruby-dev:42341]' + path = Tempfile.new("bug3910").path + 1.times do + io = open(path,"w") + io.print "hoge" + end + assert_nothing_raised(TypeError, bug3910) do + GC.start + end + end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/