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

ruby-changes:61021

From: Nobuyoshi <ko1@a...>
Date: Wed, 6 May 2020 12:45:23 +0900 (JST)
Subject: [ruby-changes:61021] 7397b9f786 (master): Fixed leaked fds

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

From 7397b9f7867b787280c1a5c955c40bd44fcb8f35 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Wed, 6 May 2020 12:45:01 +0900
Subject: Fixed leaked fds


diff --git a/test/socket/test_unix.rb b/test/socket/test_unix.rb
index 6efb1d6..e9c90be 100644
--- a/test/socket/test_unix.rb
+++ b/test/socket/test_unix.rb
@@ -542,16 +542,20 @@ class TestSocket_UNIXSocket < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/socket/test_unix.rb#L542
 
   def test_getcred_xucred
     return if /freebsd|darwin/ !~ RUBY_PLATFORM
-    Dir.mktmpdir {|d|
+    Dir.mktmpdir do |d|
       sockpath = "#{d}/sock"
       serv = Socket.unix_server_socket(sockpath)
-      Socket.unix(sockpath)
+      u = Socket.unix(sockpath)
       s, = serv.accept
       cred = s.getsockopt(0, Socket::LOCAL_PEERCRED)
       inspect = cred.inspect
       assert_match(/ euid=#{Process.euid} /, inspect)
       assert_match(/ \(xucred\)/, inspect)
-    }
+    ensure
+      s&.close
+      u&.close
+      serv&.close
+    end
   end
 
   def test_sendcred_ucred
-- 
cgit v0.10.2


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

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