The race condition should be solved by application.
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.