lib/pitchfork/info.rb in pitchfork-0.7.0 vs lib/pitchfork/info.rb in pitchfork-0.8.0
- old
+ new
@@ -27,17 +27,11 @@
@kept_ios.each_value do |io_like|
ignored_ios << (io_like.is_a?(IO) ? io_like : io_like.to_io)
end
ObjectSpace.each_object(IO) do |io|
- closed = begin
- io.closed?
- rescue IOError
- true
- end
-
- if !closed && io.autoclose? && !ignored_ios.include?(io)
+ if io_open?(io) && io_autoclosed?(io) && !ignored_ios.include?(io)
if io.is_a?(TCPSocket)
# If we inherited a TCP Socket, calling #close directly could send FIN or RST.
# So we first reopen /dev/null to avoid that.
io.reopen(File::NULL)
end
@@ -70,9 +64,23 @@
# process.
# Otherwise they may succeed while Pitchfork is draining requests causing
# more requests to be sent.
def shutting_down?
SharedMemory.shutting_down?
+ end
+
+ private
+
+ def io_open?(io)
+ !io.closed?
+ rescue IOError
+ false
+ end
+
+ def io_autoclosed?(io)
+ io.autoclose?
+ rescue IOError
+ false
end
end
end
end