[前][次][番号順一覧][スレッド一覧]

ruby-changes:61022

From: Nobuyoshi <ko1@a...>
Date: Wed, 6 May 2020 14:01:11 +0900 (JST)
Subject: [ruby-changes:61022] b247ac086e (master): Ignore FDs kept by system library

https://git.ruby-lang.org/ruby.git/commit/?id=b247ac086e

From b247ac086e60a6cee99ea1989277c5c66b0541de Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Wed, 6 May 2020 13:13:10 +0900
Subject: Ignore FDs kept by system library

`getaddrinfo` on macOS seems keeping FDs to query host names
internally.

diff --git a/tool/lib/leakchecker.rb b/tool/lib/leakchecker.rb
index 293ebe6..bd0e24b 100644
--- a/tool/lib/leakchecker.rb
+++ b/tool/lib/leakchecker.rb
@@ -89,6 +89,19 @@ class LeakChecker https://github.com/ruby/ruby/blob/trunk/tool/lib/leakchecker.rb#L89
           }.sort.each {|s|
             str << s
           }
+        else
+          begin
+            io = IO.for_fd(fd, autoclose: false)
+            s = io.stat
+          rescue Errno::EBADF
+            # something un-stat-able
+            next
+          else
+            next if /darwin/ =~ RUBY_PLATFORM and [0, -1].include?(s.dev)
+            str << ' ' << s.inspect
+          ensure
+            io.close
+          end
         end
         puts "Leaked file descriptor: #{test_name}: #{fd}#{str}"
         puts "  The IO was created at #{pos}" if pos
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]