List:Commits« Previous MessageNext Message »
From:Vladislav Vaintroub Date:November 25 2009 4:15pm
Subject:bzr commit into connector-net-5.2 branch (vvaintroub:715) Bug#31996
View as plain text  
#At file:///H:/connector_net/5.2/ based on revid:reggie.burnett@stripped

  715 Vladislav Vaintroub	2009-11-25
      - Always close connection in MySqlConnection.Dispose(), also when it is
      garbage-collected , so underlying driver can be reused in the connection
       pool (bug#31996)

    modified:
      CHANGES
      MySql.Data/Provider/Source/Connection.cs
      MySql.Data/Provider/Source/Driver.cs
      MySql.Data/Provider/Source/MySqlPool.cs
      MySql.Data/Tests/Source/ConnectionTests.cs
=== modified file 'CHANGES'
--- a/CHANGES	2009-10-23 18:39:54 +0000
+++ b/CHANGES	2009-11-25 16:15:54 +0000
@@ -1,3 +1,7 @@
+- Always close connection in MySqlConnection.Dispose(), also when it is
+garbage-collected so underlying driver can be reused in the connection pool 
+(bug#31996)
+
 Version 5.2.8
 - fixed situation where TreatTinyAsBoolean had no effect with default database character set to UTF8
     (bug#46205)

=== modified file 'MySql.Data/Provider/Source/Connection.cs'
--- a/MySql.Data/Provider/Source/Connection.cs	2009-10-22 21:29:20 +0000
+++ b/MySql.Data/Provider/Source/Connection.cs	2009-11-25 16:15:54 +0000
@@ -525,7 +525,7 @@ namespace MySql.Data.MySqlClient
 
         protected override void Dispose(bool disposing)
         {
-            if (disposing && State == ConnectionState.Open)
+            if (State == ConnectionState.Open)
                 Close();
             base.Dispose(disposing);
         }

=== modified file 'MySql.Data/Provider/Source/Driver.cs'
--- a/MySql.Data/Provider/Source/Driver.cs	2009-06-30 21:23:12 +0000
+++ b/MySql.Data/Provider/Source/Driver.cs	2009-11-25 16:15:54 +0000
@@ -72,6 +72,7 @@ namespace MySql.Data.MySqlClient
         public MySqlConnection Connection
         {
             get { return connection; }
+            set { connection = value; }
         }
 
         public int ThreadID

=== modified file 'MySql.Data/Provider/Source/MySqlPool.cs'
--- a/MySql.Data/Provider/Source/MySqlPool.cs	2009-05-29 19:35:18 +0000
+++ b/MySql.Data/Provider/Source/MySqlPool.cs	2009-11-25 16:15:54 +0000
@@ -170,6 +170,7 @@ namespace MySql.Data.MySqlClient
             {
                 lock ((idlePool as ICollection).SyncRoot)
                 {
+                    driver.Connection = null;
                     idlePool.Enqueue(driver);
                 }
             }

=== modified file 'MySql.Data/Tests/Source/ConnectionTests.cs'
--- a/MySql.Data/Tests/Source/ConnectionTests.cs	2008-05-07 14:48:48 +0000
+++ b/MySql.Data/Tests/Source/ConnectionTests.cs	2009-11-25 16:15:54 +0000
@@ -398,6 +398,29 @@ namespace MySql.Data.MySqlClient.Tests
             }
         }
 
+
+        class ConnectionClosedCheck
+        {
+            public bool closed = false;
+            public void stateChangeHandler(object sender, StateChangeEventArgs e)
+            {
+                if (e.CurrentState == ConnectionState.Closed)
+                    closed = true;
+            }
+        }
+        [Test]
+        public void ConnectionCloseByGC()
+        {
+            ConnectionClosedCheck check = new ConnectionClosedCheck();
+            string connStr = GetConnectionString(true);
+            MySqlConnection c = new MySqlConnection(connStr);
+            c.StateChange += new StateChangeEventHandler(check.stateChangeHandler);
+            c.Open();
+            c = null;
+            GC.Collect();
+            GC.WaitForPendingFinalizers();
+            Assert.IsTrue(check.closed);
+        }
 		/// <summary>
 		/// Bug #30964 StateChange imperfection 
 		/// </summary>


Attachment: [text/bzr-bundle] bzr/vvaintroub@mysql.com-20091125161554-gz4aq51092x9jxw0.bundle
Thread
bzr commit into connector-net-5.2 branch (vvaintroub:715) Bug#31996Vladislav Vaintroub25 Nov