List:Commits« Previous MessageNext Message »
From:Reggie Burnett Date:January 6 2011 4:34pm
Subject:bzr commit into connector-net-trunk branch (reggie.burnett:954)
View as plain text  
#At file:///C:/Users/Reggie/work/connector-net/trunk/ based on revid:reggie.burnett@stripped

  954 Reggie Burnett	2011-01-06 [merge]
      merged

    modified:
      CHANGES
      MySql.Data/Provider/Source/common/StreamCreator.cs
=== modified file 'CHANGES'
=== modified file 'CHANGES'
--- a/CHANGES	2010-12-22 21:22:50 +0000
+++ b/CHANGES	2011-01-06 16:34:04 +0000
@@ -1,2 +1,1 @@
 6.4.0
-<TBD>
\ No newline at end of file

=== modified file 'MySql.Data/Provider/Source/common/StreamCreator.cs'
--- a/MySql.Data/Provider/Source/common/StreamCreator.cs	2010-11-30 18:32:09 +0000
+++ b/MySql.Data/Provider/Source/common/StreamCreator.cs	2011-01-06 16:33:06 +0000
@@ -52,6 +52,40 @@
             this.keepalive = keepalive;
         }
 
+        private Stream GetStreamFromHost(string pipeName, string hostName, uint timeout)
+        {
+            Stream stream = null;
+            if (pipeName != null && pipeName.Length != 0)
+            {
+#if !CF
+                stream = NamedPipeStream.Create(pipeName, hostName, timeout);
+#endif
+            }
+            else
+            {
+                IPHostEntry ipHE = GetHostEntry(hostName);
+                foreach (IPAddress address in ipHE.AddressList)
+                {
+                    try
+                    {
+                        stream = CreateSocketStream(address, false);
+                        if (stream != null) break;
+                    }
+                    catch (Exception ex)
+                    {
+                        SocketException socketException = ex as SocketException;
+                        // if the exception is a ConnectionRefused then we eat it as we may have other address
+                        // to attempt
+                        if (socketException == null) throw;
+#if !CF
+                        if (socketException.SocketErrorCode != SocketError.ConnectionRefused) throw;
+#endif
+                    }
+                }
+            }
+            return stream;
+        }
+
         public Stream GetStream(uint timeout)
         {
             timeOut = timeout;
@@ -64,46 +98,14 @@
             Random random = new Random((int)DateTime.Now.Ticks);
             int index = random.Next(dnsHosts.Length);
             int pos = 0;
-            bool usePipe = (pipeName != null && pipeName.Length != 0);
             Stream stream = null;
 
-            while (pos < dnsHosts.Length)
+            while (stream == null && pos < dnsHosts.Length)
             {
-                try
-                {
-                    if (usePipe)
-                    {
-#if !CF
-                        stream = NamedPipeStream.Create(pipeName, dnsHosts[index], timeout);
-#endif
-                    }
-                    else
-                    {
-                        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++;
-                }
-                catch (Exception)
-                {
-                    // if on last host then throw
-                    if (pos >= dnsHosts.Length - 1) throw;
-                    // else continue
-                }
+                stream = GetStreamFromHost(pipeName, dnsHosts[index++], timeout);
+                if (index == dnsHosts.Length) index = 0;
+                pos++;
             }
-
             return stream;
         }
 

No bundle (reason: revision is a merge (you can force generation of a bundle with env var BZR_FORCE_BUNDLE=1)).
Thread
bzr commit into connector-net-trunk branch (reggie.burnett:954) Reggie Burnett6 Jan