mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
inspect IO objects before closed IO object test.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46601 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
38f013391d
commit
7361eb9462
1 changed files with 6 additions and 5 deletions
|
@ -44,20 +44,21 @@ class LeakChecker
|
||||||
leaked = true
|
leaked = true
|
||||||
h = {}
|
h = {}
|
||||||
ObjectSpace.each_object(IO) {|io|
|
ObjectSpace.each_object(IO) {|io|
|
||||||
|
inspect = io.inspect
|
||||||
begin
|
begin
|
||||||
autoclose = io.autoclose?
|
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, autoclose]
|
(h[fd] ||= []) << [io, autoclose, inspect]
|
||||||
}
|
}
|
||||||
fd_leaked.each {|fd|
|
fd_leaked.each {|fd|
|
||||||
str = ''
|
str = ''
|
||||||
if h[fd]
|
if h[fd]
|
||||||
str << ' :'
|
str << ' :'
|
||||||
h[fd].map {|io, autoclose|
|
h[fd].map {|io, autoclose, inspect|
|
||||||
s = ' ' + io.inspect
|
s = ' ' + inspect
|
||||||
s << "(not-autoclose)" if !autoclose
|
s << "(not-autoclose)" if !autoclose
|
||||||
s
|
s
|
||||||
}.sort.each {|s|
|
}.sort.each {|s|
|
||||||
|
@ -68,8 +69,8 @@ class LeakChecker
|
||||||
}
|
}
|
||||||
h.each {|fd, list|
|
h.each {|fd, list|
|
||||||
next if list.length <= 1
|
next if list.length <= 1
|
||||||
if 1 < list.count {|io, autoclose| autoclose }
|
if 1 < list.count {|io, autoclose, inspect| autoclose }
|
||||||
str = list.map {|io, autoclose| " #{io.inspect}" + (autoclose ? "(autoclose)" : "") }.sort.join
|
str = list.map {|io, autoclose, inspect| " #{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}"
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue