From 1fd1234ca5ba3d84d2182c38b37322bd55f08882 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 7 Feb 2011 16:09:53 -0800 Subject: test_helper: avoid FD leakage/waste No need to unnecessarily leave file descriptor open. --- test/test_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_helper.rb b/test/test_helper.rb index c87cc1a..d9ff90c 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -110,7 +110,7 @@ def unused_port(addr = '127.0.0.1') # when running tests in parallel with gmake. Create a lock file while # we have the port here to ensure that does not happen . lock_path = "#{Dir::tmpdir}/unicorn_test.#{addr}:#{port}.lock" - File.open(lock_path, File::WRONLY|File::CREAT|File::EXCL, 0600) + File.open(lock_path, File::WRONLY|File::CREAT|File::EXCL, 0600).close at_exit { File.unlink(lock_path) rescue nil } rescue Errno::EEXIST sock.close rescue nil -- cgit v1.2.3-24-ge0c7