List:Commits« Previous MessageNext Message »
From:rburnett Date:December 31 2006 6:06am
Subject:Connector/NET commit: r517 - in trunk: . TestSuite mysqlclient/core
View as plain text  
Modified:
   trunk/MySQLClient.2005.sln
   trunk/TestSuite/MySql.Data.Tests.2005.csproj
   trunk/TestSuite/StressTests.cs
   trunk/TestSuite/TimeoutAndCancel.cs
   trunk/mysqlclient/core/command.cs
Log:
command.cs - Added code to use an AutoResetEvent to better control when the query can be canceled.

StressTests.cs - Removed code to set the max allowed packet size from the multi packet test.  We now just launch mysql with max allowed packet set > than 16M

TimeoutAndCancel.cs - set timeout and cancel tests to working

MySql.Data.Tests.2005.csproj - updated nunit.framework reference to 2.2.9

MySQLClient.2005.sln - removed compact framework project.

Modified: trunk/MySQLClient.2005.sln
===================================================================
--- trunk/MySQLClient.2005.sln	2006-12-29 16:25:08 UTC (rev 516)
+++ trunk/MySQLClient.2005.sln	2006-12-31 06:06:53 UTC (rev 517)
@@ -4,8 +4,6 @@
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MySql.Data.Tests.2005", "TestSuite\MySql.Data.Tests.2005.csproj", "{F29E5B3D-7F76-4CF9-BF5E-8E3A1377B1E4}"
 EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MySql.Data.CF.2005", "mysqlclient\MySql.Data.CF.2005.csproj", "{19DAEB9F-F508-43A5-AB25-D66919A18259}"
-EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
@@ -28,12 +26,6 @@
 		{F29E5B3D-7F76-4CF9-BF5E-8E3A1377B1E4}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{F29E5B3D-7F76-4CF9-BF5E-8E3A1377B1E4}.Release|Any CPU.Build.0 = Release|Any CPU
 		{F29E5B3D-7F76-4CF9-BF5E-8E3A1377B1E4}.Release|x86.ActiveCfg = Release|Any CPU
-		{19DAEB9F-F508-43A5-AB25-D66919A18259}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{19DAEB9F-F508-43A5-AB25-D66919A18259}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{19DAEB9F-F508-43A5-AB25-D66919A18259}.Debug|x86.ActiveCfg = Debug|Any CPU
-		{19DAEB9F-F508-43A5-AB25-D66919A18259}.Release|Any CPU.ActiveCfg = Release|Any CPU
-		{19DAEB9F-F508-43A5-AB25-D66919A18259}.Release|Any CPU.Build.0 = Release|Any CPU
-		{19DAEB9F-F508-43A5-AB25-D66919A18259}.Release|x86.ActiveCfg = Release|Any CPU
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE

Modified: trunk/TestSuite/MySql.Data.Tests.2005.csproj
===================================================================
--- trunk/TestSuite/MySql.Data.Tests.2005.csproj	2006-12-29 16:25:08 UTC (rev 516)
+++ trunk/TestSuite/MySql.Data.Tests.2005.csproj	2006-12-31 06:06:53 UTC (rev 517)
@@ -31,7 +31,7 @@
     <WarningLevel>4</WarningLevel>
   </PropertyGroup>
   <ItemGroup>
-    <Reference Include="nunit.framework, Version=2.2.8.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL" />
+    <Reference Include="nunit.framework, Version=2.2.9.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL" />
     <Reference Include="System" />
     <Reference Include="System.configuration" />
     <Reference Include="System.Data" />

Modified: trunk/TestSuite/StressTests.cs
===================================================================
--- trunk/TestSuite/StressTests.cs	2006-12-29 16:25:08 UTC (rev 516)
+++ trunk/TestSuite/StressTests.cs	2006-12-31 06:06:53 UTC (rev 517)
@@ -56,16 +56,10 @@
 			// currently do not test this with compression
 			if (conn.UseCompression) return;
 
-			MySqlConnection c = new MySqlConnection(conn.ConnectionString + ";pooling=false");
-			c.Open();
-
 			byte[] dataIn = Utils.CreateBlob(len);
 			byte[] dataIn2 = Utils.CreateBlob(len);
 
-            MySqlCommand cmd = new MySqlCommand("SET max_allowed_packet=35000000", c);
-            cmd.ExecuteNonQuery();
-
-            cmd.CommandText = "INSERT INTO Test VALUES (?id, NULL, ?blob, NULL )";
+            MySqlCommand cmd = new MySqlCommand("INSERT INTO Test VALUES (?id, NULL, ?blob, NULL )", conn);
 			cmd.Parameters.Add(new MySqlParameter("?id", 1));
 			cmd.Parameters.Add(new MySqlParameter("?blob", dataIn));
 			try 
@@ -81,37 +75,32 @@
 			cmd.Parameters[1].Value = dataIn2;
 			cmd.ExecuteNonQuery();
 
-
 			cmd.CommandText = "SELECT * FROM Test";
-			MySqlDataReader reader = null;
-			
-			try 
-			{
-				reader = cmd.ExecuteReader();
-				reader.Read();
-				byte[] dataOut = new byte[ len ];
-				long count = reader.GetBytes(2, 0, dataOut, 0, len);
-				Assert.AreEqual(len, count);
 
-				for (int i=0; i < len; i++)
-					Assert.AreEqual(dataIn[i], dataOut[i]);
+            try
+            {
+                using (MySqlDataReader reader = cmd.ExecuteReader())
+                {
+                    reader.Read();
+                    byte[] dataOut = new byte[len];
+                    long count = reader.GetBytes(2, 0, dataOut, 0, len);
+                    Assert.AreEqual(len, count);
 
-				reader.Read();
-				count = reader.GetBytes(2, 0, dataOut, 0, len);
-				Assert.AreEqual(len, count);
+                    for (int i = 0; i < len; i++)
+                        Assert.AreEqual(dataIn[i], dataOut[i]);
 
-				for (int i=0; i < len; i++)
-					Assert.AreEqual(dataIn2[i], dataOut[i]);
-			}
-			catch (Exception ex) 
-			{
-				Assert.Fail(ex.Message);
-			}
-			finally 
-			{
-				if (reader != null) reader.Close();
-				c.Close();
-			}
+                    reader.Read();
+                    count = reader.GetBytes(2, 0, dataOut, 0, len);
+                    Assert.AreEqual(len, count);
+
+                    for (int i = 0; i < len; i++)
+                        Assert.AreEqual(dataIn2[i], dataOut[i]);
+                }
+            }
+            catch (Exception ex)
+            {
+                Assert.Fail(ex.Message);
+            }
 		}
 
 		[Test]

Modified: trunk/TestSuite/TimeoutAndCancel.cs
===================================================================
--- trunk/TestSuite/TimeoutAndCancel.cs	2006-12-29 16:25:08 UTC (rev 516)
+++ trunk/TestSuite/TimeoutAndCancel.cs	2006-12-31 06:06:53 UTC (rev 517)
@@ -21,8 +21,8 @@
 using System;
 using System.Data;
 using System.IO;
-using NUnit.Framework;
 using System.Threading;
+using NUnit.Framework;
 
 namespace MySql.Data.MySqlClient.Tests
 {
@@ -58,7 +58,6 @@
 
         [Category("5.0")]
         [Test]
-        [Category("NotWorking")]
         public void CancelSingleQuery()
         {
             // first we need a routine that will run for a bit
@@ -123,7 +122,6 @@
 
         [Category("5.0")]
         [Test]
-        [Category("NotWorking")]
         public void TimeoutExpiring()
         {
             // first we need a routine that will run for a bit

Modified: trunk/mysqlclient/core/command.cs
===================================================================
--- trunk/mysqlclient/core/command.cs	2006-12-29 16:25:08 UTC (rev 516)
+++ trunk/mysqlclient/core/command.cs	2006-12-31 06:06:53 UTC (rev 517)
@@ -54,6 +54,7 @@
 		private int commandTimeout;
 		private bool canCancel;
 		private bool timedOut;
+        private AutoResetEvent querySent;
 
 		/// <include file='docs/mysqlcommand.xml' path='docs/ctor1/*'/>
 		public MySqlCommand()
@@ -68,6 +69,7 @@
 			commandTimeout = 30;
 			canCancel = false;
 			timedOut = false;
+            querySent = new AutoResetEvent(false);
 		}
 
 		/// <include file='docs/mysqlcommand.xml' path='docs/ctor2/*'/>
@@ -318,10 +320,13 @@
 		private void TimeoutExpired(object commandObject)
 		{
 			MySqlCommand cmd = (commandObject as MySqlCommand);
-			if (cmd.canCancel)
+            // wait for the query to be sent
+            querySent.WaitOne();
+
+            if (cmd.canCancel)
 			{
-				cmd.timedOut = true;
-				cmd.Cancel();
+                cmd.timedOut = true;
+                cmd.Cancel();
 			}
 		}
 
@@ -358,43 +363,50 @@
 
 			updatedRowCount = -1;
 
-			try
-			{
-				MySqlDataReader reader = new MySqlDataReader(this, statement, behavior);
+            try
+            {
+                MySqlDataReader reader = new MySqlDataReader(this, statement, behavior);
 
-				// start a threading timer on our command timeout 
-				timedOut = false;
-				Timer t = null;
-				if (connection.driver.Version.isAtLeast(5, 0, 0) &&
-					 commandTimeout > 0)
-				{
-					TimerCallback timerDelegate =
-						 new TimerCallback(TimeoutExpired);
-					t = new Timer(timerDelegate, this, this.CommandTimeout * 1000, Timeout.Infinite);
-				}
+                // start a threading timer on our command timeout 
+                timedOut = false;
+                Timer t = null;
+                querySent.Reset();
+                if (connection.driver.Version.isAtLeast(5, 0, 0) &&
+                     commandTimeout > 0)
+                {
+                    TimerCallback timerDelegate =
+                         new TimerCallback(TimeoutExpired);
+                    t = new Timer(timerDelegate, this, this.CommandTimeout * 1000, Timeout.Infinite);
+                }
 
-				// execute the statement
-				statement.Execute(parameters);
+                // execute the statement
+                statement.Execute(parameters);
+                querySent.Set();
 
-				canCancel = true;
-				reader.NextResult();
-				if (t != null)
-					t.Dispose();
-				canCancel = false;
-				connection.Reader = reader;
-				return reader;
-			}
-			catch (MySqlException ex)
-			{
-				// if we caught an exception because of a cancel, then just return null
-				if (ex.Number == 1317)
-				{
-					if (timedOut)
-						throw new MySqlException(Resources.Timeout);
-					return null;
-				}
-				throw;
-			}
+                canCancel = true;
+                reader.NextResult();
+                if (t != null)
+                    t.Dispose();
+                canCancel = false;
+                connection.Reader = reader;
+                return reader;
+            }
+            catch (MySqlException ex)
+            {
+                // if we caught an exception because of a cancel, then just return null
+                if (ex.Number == 1317)
+                {
+                    if (timedOut)
+                        throw new MySqlException(Resources.Timeout);
+                    return null;
+                }
+                throw;
+            }
+            finally
+            {
+                querySent.Reset();
+                canCancel = false;
+            }
 		}
 
 		/// <include file='docs/mysqlcommand.xml' path='docs/ExecuteScalar/*'/>

Thread
Connector/NET commit: r517 - in trunk: . TestSuite mysqlclient/corerburnett31 Dec