From 8f9ab371418f6aa86389b859e1645c744287e0c8 Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Sun, 29 Oct 2023 21:34:00 +1300 Subject: [PATCH] Prefer to use `File.unlink`. --- lib/async/io/unix_endpoint.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/async/io/unix_endpoint.rb b/lib/async/io/unix_endpoint.rb index 4d50004..3b586e8 100644 --- a/lib/async/io/unix_endpoint.rb +++ b/lib/async/io/unix_endpoint.rb @@ -5,7 +5,6 @@ # Copyright, 2019, by Olle Jonsson. require_relative 'address_endpoint' -require 'fileutils' module Async module IO @@ -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