From: Eric Wong Date: 2013-08-24T19:06:15+00:00 Subject: [ruby-core:56800] Re: [ruby-trunk - Bug #8816][Third Party's Issue] Tempfile.new may return the same name for parallel calls "akr (Akira Tanaka)" wrote: > http://bogomips.org/kgio.git/tree/test/test_unix_connect.rb : > > class TestKgioUnixConnect < Test::Unit::TestCase > > def setup > tmp = Tempfile.new('kgio_unix') > @path = tmp.path > File.unlink(@path) > tmp.close rescue nil > @srv = Kgio::UNIXServer.new(@path) > @addr = Socket.pack_sockaddr_un(@path) > end > > The race condition should be solved by application. Agreed (kgio maintainer here). Hleb: can you send me a patch to retry on bind failure? I'm a little surprised it happens since $$ is in the Tempfile name and the tests are not multi-threaded (but optionally multi-process). > Because another process may creates the file between unlink and unix > socket creation. > Tempfile cannot do anything between them because Tempfile methods are > not running at that time. Right. I do this often in test cases, but I'm lazy and have never hit a problem even though I know it's there :x