Modified:
branches/5.2/CHANGES
branches/5.2/MySql.Data/Provider/Source/common/NamedPipeStream.cs
branches/5.2/MySql.Data/Provider/Source/common/StreamCreator.cs
Log:
- restructured the connection open error handling so that socket exceptions come through as the inner exception (bug #45021)
Modified: branches/5.2/CHANGES
===================================================================
--- branches/5.2/CHANGES 2009-05-26 20:36:32 UTC (rev 1625)
+++ branches/5.2/CHANGES 2009-05-29 20:34:45 UTC (rev 1626)
@@ -13,6 +13,8 @@
- fixed ReservedWords schema collection to not incorrectly include blank words and to use the
right column name
- fixed display of trigger names
+- restructured the connection open error handling so that socket exceptions come through
+ as the inner exception (bug #45021)
Version 5.2.6
- cleaned up how stored procedure execution operated when the user does or does not have execute privs
Modified: branches/5.2/MySql.Data/Provider/Source/common/NamedPipeStream.cs
===================================================================
--- branches/5.2/MySql.Data/Provider/Source/common/NamedPipeStream.cs 2009-05-26 20:36:32 UTC (rev 1625)
+++ branches/5.2/MySql.Data/Provider/Source/common/NamedPipeStream.cs 2009-05-29 20:34:45 UTC (rev 1626)
@@ -31,7 +31,6 @@
/// </summary>
internal class NamedPipeStream : Stream
{
-
int pipeHandle;
FileAccess _mode;
@@ -191,6 +190,16 @@
{
throw new NotSupportedException(Resources.NamedPipeNoSeek);
}
+
+ internal static NamedPipeStream Create(string pipeName, string hostname)
+ {
+ string pipePath;
+ if (0 == String.Compare(hostname, "localhost", true))
+ pipePath = @"\\.\pipe\" + pipeName;
+ else
+ pipePath = String.Format(@"\\{0}\pipe\{1}", hostname, pipeName);
+ return new NamedPipeStream(pipePath, FileAccess.ReadWrite);
+ }
}
}
Modified: branches/5.2/MySql.Data/Provider/Source/common/StreamCreator.cs
===================================================================
--- branches/5.2/MySql.Data/Provider/Source/common/StreamCreator.cs 2009-05-26 20:36:32 UTC (rev 1625)
+++ branches/5.2/MySql.Data/Provider/Source/common/StreamCreator.cs 2009-05-29 20:34:45 UTC (rev 1626)
@@ -62,35 +62,39 @@
while (pos < dnsHosts.Length)
{
+ try
+ {
+ if (usePipe)
+ {
#if !CF
- if (usePipe)
- stream = CreateNamedPipeStream(dnsHosts[index]);
- else
+ stream = NamedPipeStream.Create(pipeName, dnsHosts[index]);
#endif
- {
-#if NET20
- IPHostEntry ipHE = GetHostEntry(dnsHosts[index]);
-#else
- IPHostEntry ipHE = Dns.GetHostByName(dnsHosts[index]);
-#endif
-
- foreach (IPAddress address in ipHE.AddressList)
+ }
+ else
{
- // MySQL doesn't currently support IPv6 addresses
- if (address.AddressFamily == AddressFamily.InterNetworkV6)
- continue;
-
- stream = CreateSocketStream(address, false);
- if (stream != null)
- break;
+ IPHostEntry ipHE = GetHostEntry(dnsHosts[index]);
+ foreach (IPAddress address in ipHE.AddressList)
+ {
+ // MySQL doesn't currently support IPv6 addresses
+ if (address.AddressFamily == AddressFamily.InterNetworkV6)
+ continue;
+ stream = CreateSocketStream(address, false);
+ if (stream != null) break;
+ }
}
+ if (stream != null)
+ break;
+ index++;
+ if (index == dnsHosts.Length)
+ index = 0;
+ pos++;
}
- if (stream != null)
- break;
- index++;
- if (index == dnsHosts.Length)
- index = 0;
- pos++;
+ catch (Exception)
+ {
+ // if on last host then throw
+ if (pos >= dnsHosts.Length - 1) throw;
+ // else continue
+ }
}
return stream;
@@ -114,24 +118,11 @@
}
#if !CF
- private Stream CreateNamedPipeStream(string hostname)
- {
- string pipePath;
- if (0 == String.Compare(hostname, "localhost", true))
- pipePath = @"\\.\pipe\" + pipeName;
- else
- pipePath = String.Format(@"\\{0}\pipe\{1}", hostname, pipeName);
- return new NamedPipeStream(pipePath, FileAccess.ReadWrite);
- }
private static EndPoint CreateUnixEndPoint(string host)
{
// first we need to load the Mono.posix assembly
-#if NET20
Assembly a = Assembly.Load("Mono.Posix");
-#else
- Assembly a = Assembly.LoadWithPartialName("Mono.Posix");
-#endif
// then we need to construct a UnixEndPoint object
EndPoint ep = (EndPoint)a.CreateInstance("Mono.Posix.UnixEndPoint",
@@ -167,7 +158,7 @@
catch (Exception)
{
socket.Close();
- return null;
+ throw;
}
NetworkStream stream = new NetworkStream(socket, true);
GC.SuppressFinalize(socket);
| Thread |
|---|
| • Connector/NET commit: r1626 - in branches/5.2: . MySql.Data/Provider/Source/common | rburnett | 29 May |