dblock/heroku-forward — pull request #6 by joeyAghion (2013-01-24 21:15:44+00:00)
Title: Generate unique, temporary names for socket files in a more robust way.

The Thin back-end generates a default socket filename by calling `Tempfile.open`:

```ruby
Tempfile.open 'thin' do |file|
return file.path
end
```

However, this does more than generate a nicely unique name; it actually creates the file then frees it to be deleted at the close of the block. Garbage collection will delete it next time it runs. (Note that, as far as we know, this hasn't dinged us in production. Maybe the fact that the proxy process has started writing to the file prevents the delete?)

This commit adds a `Utils.tmp_filename` helper for this purpose instead. It's based on ruby 1.9's [`Dir::Tmpname.make_tmpname`](http://www.rdoc.info/stdlib/tmpdir/1.9.2/Dir/Tmpname#make_tmpname-instance_method). New specs assert that the generated filename doesn't exist before server start, and that later garbage-collection doesn't delete the socket.