List:Commits« Previous MessageNext Message »
From:rburnett Date:September 14 2006 8:12pm
Subject:Connector/NET commit: r337 - in trunk: TestSuite mysqlclient mysqlclient/common
View as plain text  
Modified:
   trunk/TestSuite/CommandTests.cs
   trunk/mysqlclient/CharSetMap.cs
   trunk/mysqlclient/MySql.Data.2005.csproj
   trunk/mysqlclient/command.cs
   trunk/mysqlclient/common/SocketStream.cs
   trunk/mysqlclient/common/StreamCreator.cs
Log:
command.cs
-------------
removed an extra trace call and calling dispose on the timer when we are done with it.

SocketStream.cs
---------------
Open now throws a SocketException instead of Exception.  This matches what Socket.Open() would throw.

StreamCreator.cs
-----------------
Rewrote the create stream part to not use temp arrays and to not do dns resolve on all given hostnames.  Now, failures will not log themselves but overall failure will throw a MySqlException.  This allows an IPV6 failure to silently drop to IPV4.

CommandTests.cs
-----------------
Removed Explicit nunit attribute from rest of test cases (they should all work now)




Modified: trunk/TestSuite/CommandTests.cs
===================================================================
--- trunk/TestSuite/CommandTests.cs	2006-09-13 20:05:50 UTC (rev 336)
+++ trunk/TestSuite/CommandTests.cs	2006-09-14 20:12:34 UTC (rev 337)
@@ -491,7 +491,6 @@
         }
     }
 
-    [Explicit]
     public class CommandTestsSharedMemory : CommandTests
     {
         protected override string GetConnectionInfo()
@@ -500,7 +499,6 @@
         }
     }
 
-    [Explicit]
     public class CommandTestsSharedMemoryCompressed : CommandTests
     {
         protected override string GetConnectionInfo()

Modified: trunk/mysqlclient/CharSetMap.cs
===================================================================
--- trunk/mysqlclient/CharSetMap.cs	2006-09-13 20:05:50 UTC (rev 336)
+++ trunk/mysqlclient/CharSetMap.cs	2006-09-14 20:12:34 UTC (rev 337)
@@ -74,7 +74,6 @@
 		/// </summary>
 		private static void InitializeMapping()
 		{
-            Logger.LogInformation("Initializing character set mapping array");
 			LoadCharsetMap();
 		}
 

Modified: trunk/mysqlclient/MySql.Data.2005.csproj
===================================================================
--- trunk/mysqlclient/MySql.Data.2005.csproj	2006-09-13 20:05:50 UTC (rev 336)
+++ trunk/mysqlclient/MySql.Data.2005.csproj	2006-09-14 20:12:34 UTC (rev 337)
@@ -68,6 +68,28 @@
     <TreatWarningsAsErrors>false</TreatWarningsAsErrors>
     <WarningLevel>4</WarningLevel>
   </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
+    <DebugSymbols>true</DebugSymbols>
+    <OutputPath>bin\x86\Debug\</OutputPath>
+    <DefineConstants>TRACE;DEBUG;WINDOWS NET20</DefineConstants>
+    <BaseAddress>285212672</BaseAddress>
+    <DocumentationFile>doc.xml</DocumentationFile>
+    <PlatformTarget>x86</PlatformTarget>
+    <CodeAnalysisRuleAssemblies>C:\Program Files\Microsoft Visual Studio 8\Team Tools\Static Analysis Tools\FxCop\\rules</CodeAnalysisRuleAssemblies>
+    <CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
+    <CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
+    <OutputPath>bin\x86\Release\</OutputPath>
+    <DefineConstants>TRACE;WINDOWS NET20</DefineConstants>
+    <BaseAddress>285212672</BaseAddress>
+    <DocumentationFile>doc.xml</DocumentationFile>
+    <Optimize>true</Optimize>
+    <PlatformTarget>x86</PlatformTarget>
+    <CodeAnalysisRuleAssemblies>C:\Program Files\Microsoft Visual Studio 8\Team Tools\Static Analysis Tools\FxCop\\rules</CodeAnalysisRuleAssemblies>
+    <CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
+    <CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
+  </PropertyGroup>
   <ItemGroup>
     <Reference Include="ICSharpCode.SharpZipLib, Version=0.81.0.1407, Culture=neutral, PublicKeyToken=1b03e6acf1164f73">
       <SpecificVersion>False</SpecificVersion>

Modified: trunk/mysqlclient/command.cs
===================================================================
--- trunk/mysqlclient/command.cs	2006-09-13 20:05:50 UTC (rev 336)
+++ trunk/mysqlclient/command.cs	2006-09-14 20:12:34 UTC (rev 337)
@@ -240,7 +240,6 @@
             MySqlConnection c = new MySqlConnection(connection.Settings.GetConnectionString(true));
             try
             {
-                Trace.WriteLine("connstr = " + c.ConnectionString);
                 c.Open();
                 MySqlCommand cmd = new MySqlCommand(String.Format("KILL QUERY {0}",
                     connection.ServerThread), c);
@@ -363,11 +362,12 @@
 
                 // start a threading timer on our command timeout 
                 timedOut = false;
+                Timer t = null;
                 if (connection.driver.Version.isAtLeast(5, 0, 0))
                 {
                     TimerCallback timerDelegate =
                         new TimerCallback(TimeoutExpired);
-                    Timer t = new Timer(timerDelegate, this, this.CommandTimeout * 1000, Timeout.Infinite);
+                    t = new Timer(timerDelegate, this, this.CommandTimeout * 1000, Timeout.Infinite);
                 }
 
                 // execute the statement
@@ -375,6 +375,8 @@
 
                 canCancel = true;
                 reader.NextResult();
+                if (t != null)
+                    t.Dispose();
                 canCancel = false;
                 connection.Reader = reader;
                 return reader;

Modified: trunk/mysqlclient/common/SocketStream.cs
===================================================================
--- trunk/mysqlclient/common/SocketStream.cs	2006-09-13 20:05:50 UTC (rev 336)
+++ trunk/mysqlclient/common/SocketStream.cs	2006-09-14 20:12:34 UTC (rev 337)
@@ -114,9 +114,9 @@
 				buff[i] = addr[i];
 
 			int result = NativeMethods.connect(socket.Handle, buff, addr.Size);
-			int wsaerror = NativeMethods.WSAGetLastError();
-			if (wsaerror != 10035)
-				throw new Exception("Error creating MySQLSocket");
+            int wsaerror = NativeMethods.WSAGetLastError();
+            if (wsaerror != 10035)
+                throw new SocketException(wsaerror);
 
 			// next we wait for our connect timeout or until the socket is connected
 			ArrayList write = new ArrayList();

Modified: trunk/mysqlclient/common/StreamCreator.cs
===================================================================
--- trunk/mysqlclient/common/StreamCreator.cs	2006-09-13 20:05:50 UTC (rev 336)
+++ trunk/mysqlclient/common/StreamCreator.cs	2006-09-14 20:12:34 UTC (rev 337)
@@ -56,43 +56,40 @@
 				return CreateSocketStream(null, 0, true);
 
 			string [] dnsHosts = hostList.Split('&');
-			ArrayList ipAddresses = new ArrayList();
-			ArrayList hostNames = new ArrayList();
 
-			//
-			// Each host name specified may contain multiple IP addresses
-			// Lets look at the DNS entries for each host name
-			foreach (string h in dnsHosts)
-			{
+            System.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)
+            {
+                if (usePipe)
+                    stream = CreateNamedPipeStream(dnsHosts[index]);
+                else
+                {
 #if NET20
-                IPHostEntry hostAddress = Dns.GetHostEntry(h);
+                    IPHostEntry ipHE = Dns.GetHostEntry(dnsHosts[index]);
 #else
-				IPHostEntry hostAddress = Dns.GetHostByName(h);
+				    IPHostEntry ipHE = Dns.GetHostByName(dnsHosts[index]);
 #endif
-				foreach (IPAddress addr in hostAddress.AddressList)
-				{
-					ipAddresses.Add( addr );
-					hostNames.Add( hostAddress.HostName );
-				}
-			}
 
-			System.Random random = new Random((int)DateTime.Now.Ticks);
-			int index = random.Next(ipAddresses.Count);
+                    foreach (IPAddress address in ipHE.AddressList)
+                    {
+                        stream = CreateSocketStream(address, port, false);
+                        if (stream != null)
+                            break;
+                    }
+                }
+                if (stream != null)
+                    break;
+                index++;
+                if (index == dnsHosts.Length)
+                    index = 0;
+                pos++;
+            }
 
-			bool usePipe = (pipeName != null && pipeName.Length != 0);
-			Stream stream = null;
-			for (int i=0; i < ipAddresses.Count; i++)
-			{
-				if (usePipe)
-					stream = CreateNamedPipeStream( (string)hostNames[index] );
-				else
-					stream = CreateSocketStream( (IPAddress)ipAddresses[index], port, false );
-				if (stream != null) return stream;
-
-				index++;
-				if (index == ipAddresses.Count) index = 0;
-			}
-
 			return stream;
 		}
 
@@ -138,30 +135,14 @@
 
                 ss = unix ?
                     new SocketStream(AddressFamily.Unix, SocketType.Stream, ProtocolType.IP) :
-                    new SocketStream(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
+                    new SocketStream(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP);
                 ss.Connect(endPoint, (int)timeOut);
+                return ss;
             }
-            catch (ArgumentOutOfRangeException are)
+            catch (Exception)
             {
-                Logger.LogException(are);
-                ss = null;
+                return null;
             }
-            catch (SocketException se)
-            {
-                Logger.LogException(se);
-                ss = null;
-            }
-            catch (ObjectDisposedException ode)
-            {
-                Logger.LogException(ode);
-                ss = null;
-            }
-            catch (MySqlException me)
-            {
-                Logger.LogException(me);
-                ss = null;
-            }
-            return ss;
         }
  
 	}

Thread
Connector/NET commit: r337 - in trunk: TestSuite mysqlclient mysqlclient/commonrburnett14 Sep