mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* io.c (rb_io_autoclose_p): Don't raise on frozen IO.
* test/lib/minitest/unit.rb: IO#autoclose? may raise IOError. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46165 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
6eb8acae90
commit
1c35277c2b
4 changed files with 21 additions and 8 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
Tue May 27 19:07:26 2014 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* io.c (rb_io_autoclose_p): Don't raise on frozen IO.
|
||||||
|
|
||||||
|
* test/lib/minitest/unit.rb: IO#autoclose? may raise IOError.
|
||||||
|
|
||||||
Tue May 27 19:01:49 2014 SHIBATA Hiroshi <shibata.hiroshi@gmail.com>
|
Tue May 27 19:01:49 2014 SHIBATA Hiroshi <shibata.hiroshi@gmail.com>
|
||||||
|
|
||||||
* test/openssl/test_pair.rb: Modify TestSSL#test_read_and_write
|
* test/openssl/test_pair.rb: Modify TestSSL#test_read_and_write
|
||||||
|
|
4
io.c
4
io.c
|
@ -7607,8 +7607,8 @@ rb_io_s_for_fd(int argc, VALUE *argv, VALUE klass)
|
||||||
static VALUE
|
static VALUE
|
||||||
rb_io_autoclose_p(VALUE io)
|
rb_io_autoclose_p(VALUE io)
|
||||||
{
|
{
|
||||||
rb_io_t *fptr;
|
rb_io_t *fptr = RFILE(io)->fptr;
|
||||||
GetOpenFile(io, fptr);
|
rb_io_check_closed(fptr);
|
||||||
return (fptr->mode & FMODE_PREP) ? Qfalse : Qtrue;
|
return (fptr->mode & FMODE_PREP) ? Qfalse : Qtrue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1009,19 +1009,20 @@ module MiniTest
|
||||||
h = {}
|
h = {}
|
||||||
ObjectSpace.each_object(IO) {|io|
|
ObjectSpace.each_object(IO) {|io|
|
||||||
begin
|
begin
|
||||||
|
autoclose = io.autoclose?
|
||||||
fd = io.fileno
|
fd = io.fileno
|
||||||
rescue IOError # closed IO object
|
rescue IOError # closed IO object
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
(h[fd] ||= []) << io
|
(h[fd] ||= []) << [io, autoclose]
|
||||||
}
|
}
|
||||||
fd_leaked.each {|fd|
|
fd_leaked.each {|fd|
|
||||||
str = ''
|
str = ''
|
||||||
if h[fd]
|
if h[fd]
|
||||||
str << ' :'
|
str << ' :'
|
||||||
h[fd].map {|io|
|
h[fd].map {|io, autoclose|
|
||||||
s = ' ' + io.inspect
|
s = ' ' + io.inspect
|
||||||
s << "(not-autoclose)" if !io.autoclose?
|
s << "(not-autoclose)" if !autoclose
|
||||||
s
|
s
|
||||||
}.each {|s|
|
}.each {|s|
|
||||||
str << s
|
str << s
|
||||||
|
@ -1029,9 +1030,8 @@ module MiniTest
|
||||||
end
|
end
|
||||||
puts "Leaked file descriptor: #{name}: #{fd}#{str}"
|
puts "Leaked file descriptor: #{name}: #{fd}#{str}"
|
||||||
}
|
}
|
||||||
h.each {|fd, ios|
|
h.each {|fd, list|
|
||||||
next if ios.length <= 1
|
next if list.length <= 1
|
||||||
list = ios.map {|io| [io, io.autoclose?] }
|
|
||||||
if 1 < list.count {|io, autoclose| autoclose }
|
if 1 < list.count {|io, autoclose| autoclose }
|
||||||
str = list.map {|io, autoclose| " #{io.inspect}" + (autoclose ? "(autoclose)" : "") }.sort.join
|
str = list.map {|io, autoclose| " #{io.inspect}" + (autoclose ? "(autoclose)" : "") }.sort.join
|
||||||
puts "Multiple autoclose IO object for a file descriptor:#{str}"
|
puts "Multiple autoclose IO object for a file descriptor:#{str}"
|
||||||
|
|
|
@ -2796,6 +2796,13 @@ End
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_frozen_autoclose
|
||||||
|
with_pipe do |r,w|
|
||||||
|
fd = r.fileno
|
||||||
|
assert_equal(true, r.freeze.autoclose?)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def test_sysread_locktmp
|
def test_sysread_locktmp
|
||||||
bug6099 = '[ruby-dev:45297]'
|
bug6099 = '[ruby-dev:45297]'
|
||||||
buf = " " * 100
|
buf = " " * 100
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue