Skip to content

Commit 2fdd3ac

Browse files
committed
Use UnixDomainSocketEndPoint. Fixes #1160
Signed-off-by: Bradley Grainger <[email protected]>
1 parent c4c949c commit 2fdd3ac

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/MySqlConnector/Core/ServerSession.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1141,7 +1141,7 @@ private async Task<bool> OpenUnixSocketAsync(ConnectionSettings cs, IOBehavior i
11411141
m_logArguments[1] = cs.UnixSocket;
11421142
Log.Trace("Session{0} connecting to UNIX Socket '{1}'", m_logArguments);
11431143
var socket = new Socket(AddressFamily.Unix, SocketType.Stream, ProtocolType.IP);
1144-
var unixEp = new UnixEndPoint(cs.UnixSocket!);
1144+
var unixEp = new UnixDomainSocketEndPoint(cs.UnixSocket!);
11451145
try
11461146
{
11471147
using (cancellationToken.Register(() => socket.Dispose()))

src/MySqlConnector/Utilities/UnixEndPoint.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#if !NETSTANDARD2_1_OR_GREATER && !NETCOREAPP3_1_OR_GREATER
12
#pragma warning disable SA1005 // Single line comments should begin with single space
23
#pragma warning disable SA1120 // Comments should contain text
34
#pragma warning disable SA1512 // Single-line comments should not be followed by blank line
@@ -41,9 +42,9 @@
4142

4243
namespace MySqlConnector.Utilities;
4344

44-
internal sealed class UnixEndPoint : EndPoint
45+
internal sealed class UnixDomainSocketEndPoint : EndPoint
4546
{
46-
public UnixEndPoint(string filename)
47+
public UnixDomainSocketEndPoint(string filename)
4748
{
4849
if (filename is null)
4950
throw new ArgumentNullException (nameof(filename));
@@ -52,7 +53,7 @@ public UnixEndPoint(string filename)
5253
Filename = filename;
5354
}
5455

55-
private UnixEndPoint() => Filename = "";
56+
private UnixDomainSocketEndPoint() => Filename = "";
5657

5758
public string Filename { get; }
5859

@@ -63,7 +64,7 @@ public override EndPoint Create(SocketAddress socketAddress)
6364
if (socketAddress.Size == 2) {
6465
// Empty filename.
6566
// Probably from RemoteEndPoint which on linux does not return the file name.
66-
return new UnixEndPoint();
67+
return new UnixDomainSocketEndPoint();
6768
}
6869
var size = socketAddress.Size - 2;
6970
var bytes = new byte[size];
@@ -76,7 +77,7 @@ public override EndPoint Create(SocketAddress socketAddress)
7677
}
7778
}
7879

79-
return new UnixEndPoint(Encoding.UTF8.GetString(bytes, 0, size));
80+
return new UnixDomainSocketEndPoint(Encoding.UTF8.GetString(bytes, 0, size));
8081
}
8182

8283
public override SocketAddress Serialize()
@@ -97,5 +98,6 @@ public override SocketAddress Serialize()
9798

9899
public override int GetHashCode() => Filename.GetHashCode ();
99100

100-
public override bool Equals(object? obj) => obj is UnixEndPoint other && Filename == other.Filename;
101+
public override bool Equals(object? obj) => obj is UnixDomainSocketEndPoint other && Filename == other.Filename;
101102
}
103+
#endif

0 commit comments

Comments
 (0)