* 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29415 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
a413c84e54
commit
915ae780c3
@ -1,3 +1,10 @@
|
|||||||
|
Wed Oct 6 11:52:12 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* 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.
|
||||||
|
|
||||||
Tue Oct 5 22:17:02 2010 wanabe <s.wanabe@gmail.com>
|
Tue Oct 5 22:17:02 2010 wanabe <s.wanabe@gmail.com>
|
||||||
|
|
||||||
* win32/mkexports.rb: revert r29320 and r29402.
|
* win32/mkexports.rb: revert r29320 and r29402.
|
||||||
|
10
io.c
10
io.c
@ -3459,7 +3459,7 @@ fptr_finalize(rb_io_t *fptr, int noraise)
|
|||||||
{
|
{
|
||||||
VALUE err = Qnil;
|
VALUE err = Qnil;
|
||||||
if (fptr->writeconv) {
|
if (fptr->writeconv) {
|
||||||
if (fptr->write_lock) {
|
if (fptr->write_lock && !noraise) {
|
||||||
struct finish_writeconv_arg arg;
|
struct finish_writeconv_arg arg;
|
||||||
arg.fptr = fptr;
|
arg.fptr = fptr;
|
||||||
arg.noalloc = noraise;
|
arg.noalloc = noraise;
|
||||||
@ -3470,8 +3470,14 @@ fptr_finalize(rb_io_t *fptr, int noraise)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (fptr->wbuf_len) {
|
if (fptr->wbuf_len) {
|
||||||
|
if (noraise) {
|
||||||
|
if ((int)io_flush_buffer_sync(fptr) < 0 && NIL_P(err))
|
||||||
|
err = Qtrue;
|
||||||
|
}
|
||||||
|
else {
|
||||||
if (io_fflush(fptr) < 0 && NIL_P(err))
|
if (io_fflush(fptr) < 0 && NIL_P(err))
|
||||||
err = noraise ? Qtrue : INT2NUM(errno);
|
err = INT2NUM(errno);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (IS_PREP_STDIO(fptr) || fptr->fd <= 2) {
|
if (IS_PREP_STDIO(fptr) || fptr->fd <= 2) {
|
||||||
goto skip_fd_close;
|
goto skip_fd_close;
|
||||||
|
@ -1625,4 +1625,33 @@ End
|
|||||||
end
|
end
|
||||||
end.each {|th| th.join}
|
end.each {|th| th.join}
|
||||||
end
|
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
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user