-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Closed
Labels
area-System.Net.SocketsenhancementProduct code improvement that does NOT require public API changes/additionsProduct code improvement that does NOT require public API changes/additions
Milestone
Description
aspnetcore repo has an open issue about unix socket not getting cleaned up on exit: dotnet/aspnetcore#14134.
The socket path of a unix domain socket acts as the address.
When the Socket gets disposed, we should make the address available by deleting the file.
With the current behavior, this program fails:
using System;
using System.Net.Sockets;
namespace console
{
class Program
{
static void Main(string[] args)
{
var endpoint = new UnixDomainSocketEndPoint("/tmp/mysocket");
var socket = new Socket(AddressFamily.Unix, SocketType.Stream, ProtocolType.Unspecified);
socket.Bind(endpoint);
socket.Dispose();
socket = new Socket(AddressFamily.Unix, SocketType.Stream, ProtocolType.Unspecified);
socket.Bind(endpoint);
}
}
}$ dotnet run
Unhandled exception. System.Net.Sockets.SocketException (98): Address already in use
at System.Net.Sockets.Socket.UpdateStatusAfterSocketErrorAndThrowException(SocketError error, String callerName) in /_/src/System.Net.Sockets/src/System/Net/Sockets/Socket.cs:line 5111
at System.Net.Sockets.Socket.DoBind(EndPoint endPointSnapshot, SocketAddress socketAddress) in /_/src/System.Net.Sockets/src/System/Net/Sockets/Socket.cs:line 738
at System.Net.Sockets.Socket.Bind(EndPoint localEP) in /_/src/System.Net.Sockets/src/System/Net/Sockets/Socket.cs:line 703
at console.Program.Main(String[] args) in /tmp/console/Program.cs:line 15
Deleting the file is a visible change, so we should consider backwards compatibility.
Users are likely to have File.Delete already in their applications. Those calls will no-op (on ENOENT).
@wfurt @antonfirsov @stephentoub @dotnet/ncl what do you think?
Metadata
Metadata
Assignees
Labels
area-System.Net.SocketsenhancementProduct code improvement that does NOT require public API changes/additionsProduct code improvement that does NOT require public API changes/additions