Skip to content
This repository has been archived by the owner on Aug 29, 2024. It is now read-only.

Commit

Permalink
Prefer to use File.unlink.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Oct 29, 2023
1 parent fac06b9 commit 8f9ab37
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions lib/async/io/unix_endpoint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
# Copyright, 2019, by Olle Jonsson.

require_relative 'address_endpoint'
require 'fileutils'

module Async
module IO
Expand Down Expand Up @@ -37,7 +36,7 @@ def bind(&block)
rescue Errno::EADDRINUSE
# If you encounter EADDRINUSE from `bind()`, you can check if the socket is actually accepting connections by attempting to `connect()` to it. If the socket is still bound by an active process, the connection will succeed. Otherwise, it should be safe to `unlink()` the path and try again.
if !bound?
FileUtils.safe_unlink(@path)
File.unlink(@path) rescue nil
retry
else
raise
Expand Down

0 comments on commit 8f9ab37

Please sign in to comment.