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

Commit 2328451

Browse files
authored
Fix for socket file not being reused even when not bound
In my machine, when I `Ctrl+C` (using falcon supervisor), supervisor.ipc remains and when I restart the server, I get EADDRINUSE Found that `File.exist?(@path)` is returning false for such a file even though `ls -al` lists the file Using `FileUtils.safe_unlink` instead of `File.unlink` to safely remove the file when it exists without any error
1 parent 56fcfe8 commit 2328451

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/async/io/unix_endpoint.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ def bind(&block)
3535
Socket.bind(@address, **@options, &block)
3636
rescue Errno::EADDRINUSE
3737
# 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.
38-
if !bound? && File.exist?(@path)
39-
File.unlink(@path)
38+
if !bound?
39+
FileUtils.safe_unlink(@path)
4040
retry
4141
else
4242
raise

0 commit comments

Comments
 (0)