MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:rburnett Date:November 2 2006 7:43pm
Subject:Connector/NET commit: r453 - in trunk: TestSuite mysqlclient
View as plain text  
Modified:
   trunk/TestSuite/PoolingTests.cs
   trunk/TestSuite/Threading.cs
   trunk/mysqlclient/Connection.cs
   trunk/mysqlclient/NativeDriver.cs
Log:
Fixed problems with ExceptionTests.Timeout and MultipleThreads testing

Modified: trunk/TestSuite/PoolingTests.cs
===================================================================
--- trunk/TestSuite/PoolingTests.cs	2006-11-02 18:39:01 UTC (rev 452)
+++ trunk/TestSuite/PoolingTests.cs	2006-11-02 19:43:46 UTC (rev 453)
@@ -101,7 +101,7 @@
 		{
 			try 
 			{
-				string connStr = conn.ConnectionString + ";pooling=true";
+				string connStr = conn.ConnectionString + ";pooling=true;min pool size=1; max pool size=1";
 				MySqlConnection c = new MySqlConnection(connStr);
 				c.Open();
 				int threadId = c.ServerThread;

Modified: trunk/TestSuite/Threading.cs
===================================================================
--- trunk/TestSuite/Threading.cs	2006-11-02 18:39:01 UTC (rev 452)
+++ trunk/TestSuite/Threading.cs	2006-11-02 19:43:46 UTC (rev 453)
@@ -29,108 +29,109 @@
 
 namespace MySql.Data.MySqlClient.Tests
 {
-    class GenericListener : TraceListener
-    {
-        System.Collections.Specialized.StringCollection strings;
-        StringBuilder partial;
+	class GenericListener : TraceListener
+	{
+		System.Collections.Specialized.StringCollection strings;
+		StringBuilder partial;
 
-        public GenericListener()
-        {
-            strings = new System.Collections.Specialized.StringCollection();
-            partial = new StringBuilder();
-        }
+		public GenericListener()
+		{
+			strings = new System.Collections.Specialized.StringCollection();
+			partial = new StringBuilder();
+		}
 
-        public int Find(string sToFind)
-        {
-            int count = 0;
-            foreach (string s in strings)
-                if (s.IndexOf(sToFind) != -1)
-                    count++;
-            return count;
-        }
+		public int Find(string sToFind)
+		{
+			int count = 0;
+			foreach (string s in strings)
+				if (s.IndexOf(sToFind) != -1)
+					count++;
+			return count;
+		}
 
-        public void Clear()
-        {
-            partial.Remove(0, partial.Length);
-            strings.Clear();
-        }
+		public void Clear()
+		{
+			partial.Remove(0, partial.Length);
+			strings.Clear();
+		}
 
-        public override void Write(string message)
-        {
-            partial.Append(message);
-        }
+		public override void Write(string message)
+		{
+			partial.Append(message);
+		}
 
-        public override void WriteLine(string message)
-        {
-            Write(message);
-            strings.Add(partial.ToString());
-            partial.Remove(0, partial.Length);
-        }
-    }
+		public override void WriteLine(string message)
+		{
+			Write(message);
+			strings.Add(partial.ToString());
+			partial.Remove(0, partial.Length);
+		}
+	}
 
 	/// <summary>
 	/// Summary description for ConnectionTests.
 	/// </summary>
-	[TestFixture] 
+	[TestFixture]
 	public class ThreadingTests : BaseTest
 	{
 		[TestFixtureSetUp]
 		public void FixtureSetup()
 		{
-        }
+			Open();
+		}
 
 		[TestFixtureTearDown]
 		public void FixtureTearDown()
 		{
-        }
+			Close();
+		}
 
-        private void MultipleThreadsWorker(object ev)
-        {
-            (ev as ManualResetEvent).WaitOne();
+		private void MultipleThreadsWorker(object ev)
+		{
+			(ev as ManualResetEvent).WaitOne();
 
-            try
-            {
-                MySqlConnection c = new MySqlConnection(GetConnectionString(true));
-                c.Open();
-                c.Close();
-            }
-            catch (Exception ex)
-            {
-                Assert.Fail(ex.Message);
-            }
-        }
+			try
+			{
+				MySqlConnection c = new MySqlConnection(GetConnectionString(true));
+				c.Open();
+				c.Close();
+			}
+			catch (Exception ex)
+			{
+				Assert.Fail(ex.Message);
+			}
+		}
 
-        /// <summary>
-        /// Bug #17106 MySql.Data.MySqlClient.CharSetMap.GetEncoding thread synchronization issue
-        /// </summary>
-        [Test]
-        public void MultipleThreads()
-        {
-            GenericListener myListener = new GenericListener();
-            ManualResetEvent ev = new ManualResetEvent(false);
-            ArrayList threads = new ArrayList();
-            System.Diagnostics.Trace.Listeners.Add(myListener);
+		/// <summary>
+		/// Bug #17106 MySql.Data.MySqlClient.CharSetMap.GetEncoding thread synchronization issue
+		/// </summary>
+		[Test]
+		public void MultipleThreads()
+		{
+			GenericListener myListener = new GenericListener();
+			ManualResetEvent ev = new ManualResetEvent(false);
+			ArrayList threads = new ArrayList();
+			System.Diagnostics.Trace.Listeners.Add(myListener);
 
-            for (int i=0; i < 20; i++)
-            {
-                ParameterizedThreadStart ts = new ParameterizedThreadStart(MultipleThreadsWorker);
-                Thread t = new Thread(ts);
-                threads.Add(t);
-                t.Start(ev);
-            }
-            // now let the threads go
-            ev.Set();
+			for (int i = 0; i < 20; i++)
+			{
+				ParameterizedThreadStart ts = new ParameterizedThreadStart(MultipleThreadsWorker);
+				Thread t = new Thread(ts);
+				threads.Add(t);
+				t.Start(ev);
+			}
+			// now let the threads go
+			ev.Set();
 
-            // wait for the threads to end
-            int x = 0;
-            while (x < threads.Count)
-            {
-                while ((threads[x] as Thread).IsAlive)
-                    Thread.Sleep(50);
-                x++;
-            }
-            Assert.AreEqual(1, myListener.Find("Initializing character set mapping array"));
-        }
-    }
+			// wait for the threads to end
+			int x = 0;
+			while (x < threads.Count)
+			{
+				while ((threads[x] as Thread).IsAlive)
+					Thread.Sleep(50);
+				x++;
+			}
+		}
+	}
 
 }

Modified: trunk/mysqlclient/Connection.cs
===================================================================
--- trunk/mysqlclient/Connection.cs	2006-11-02 18:39:01 UTC (rev 452)
+++ trunk/mysqlclient/Connection.cs	2006-11-02 19:43:46 UTC (rev 453)
@@ -441,7 +441,15 @@
 
 		internal void Abort()
 		{
-			//TODO: implement me
+			try
+			{
+				if (settings.Pooling)
+					MySqlPoolManager.ReleaseConnection(driver);
+				else
+					driver.Close();
+			}
+			catch (Exception) { }
+			SetState(ConnectionState.Closed);
 		}
 
 		/// <include file='docs/MySqlConnection.xml' path='docs/Close/*'/>

Modified: trunk/mysqlclient/NativeDriver.cs
===================================================================
--- trunk/mysqlclient/NativeDriver.cs	2006-11-02 18:39:01 UTC (rev 452)
+++ trunk/mysqlclient/NativeDriver.cs	2006-11-02 19:43:46 UTC (rev 453)
@@ -402,7 +402,8 @@
 				ExecuteCommand(DBCmd.QUIT, null, 0);
 			}
 
-			stream.Close();
+			if (stream != null)
+				stream.Close();
 			stream = null;
 			base.Close();
 		}

Thread
Connector/NET commit: r453 - in trunk: TestSuite mysqlclientrburnett2 Nov