Skip to content

Commit b1ca5af

Browse files
authored
Merge pull request #1163 from bgrainger/unix-socket
Replace UnixEndPoint with UnixDomainSocketEndPoint on netstandard2.1.
2 parents c4c949c + 26a4670 commit b1ca5af

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
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 renamed to src/MySqlConnector/Utilities/UnixDomainSocketEndPoint.cs

Lines changed: 9 additions & 9 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
@@ -35,15 +36,13 @@
3536
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
3637
//
3738

38-
using System.Net;
39-
using System.Net.Sockets;
4039
using System.Text;
4140

42-
namespace MySqlConnector.Utilities;
41+
namespace System.Net.Sockets;
4342

44-
internal sealed class UnixEndPoint : EndPoint
43+
internal sealed class UnixDomainSocketEndPoint : EndPoint
4544
{
46-
public UnixEndPoint(string filename)
45+
public UnixDomainSocketEndPoint(string filename)
4746
{
4847
if (filename is null)
4948
throw new ArgumentNullException (nameof(filename));
@@ -52,7 +51,7 @@ public UnixEndPoint(string filename)
5251
Filename = filename;
5352
}
5453

55-
private UnixEndPoint() => Filename = "";
54+
private UnixDomainSocketEndPoint() => Filename = "";
5655

5756
public string Filename { get; }
5857

@@ -63,7 +62,7 @@ public override EndPoint Create(SocketAddress socketAddress)
6362
if (socketAddress.Size == 2) {
6463
// Empty filename.
6564
// Probably from RemoteEndPoint which on linux does not return the file name.
66-
return new UnixEndPoint();
65+
return new UnixDomainSocketEndPoint();
6766
}
6867
var size = socketAddress.Size - 2;
6968
var bytes = new byte[size];
@@ -76,7 +75,7 @@ public override EndPoint Create(SocketAddress socketAddress)
7675
}
7776
}
7877

79-
return new UnixEndPoint(Encoding.UTF8.GetString(bytes, 0, size));
78+
return new UnixDomainSocketEndPoint(Encoding.UTF8.GetString(bytes, 0, size));
8079
}
8180

8281
public override SocketAddress Serialize()
@@ -97,5 +96,6 @@ public override SocketAddress Serialize()
9796

9897
public override int GetHashCode() => Filename.GetHashCode ();
9998

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

0 commit comments

Comments
 (0)