MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:rburnett Date:June 17 2009 6:26pm
Subject:Connector/NET commit: r1651 - in branches/5.2: . MySql.Data/Provider/Source MySql.Data/Provider/Source/common
View as plain text  
Modified:
   branches/5.2/CHANGES
   branches/5.2/MySql.Data/Provider/Source/CompressedStream.cs
   branches/5.2/MySql.Data/Provider/Source/common/Platform.cs
Log:
- added workaround for an apparent problem with WeakReferences and threads in the mono runtime
  (bug #45463).  For now we just don't use WeakReferences on mono


Modified: branches/5.2/CHANGES
===================================================================
--- branches/5.2/CHANGES	2009-06-16 16:23:20 UTC (rev 1650)
+++ branches/5.2/CHANGES	2009-06-17 18:26:27 UTC (rev 1651)
@@ -15,6 +15,8 @@
 - fixed display of trigger names  
 - restructured the connection open error handling so that socket exceptions come through 
   as the inner exception (bug #45021)  
+- added workaround for an apparent problem with WeakReferences and threads in the mono runtime
+  (bug #45463)
   
 Version 5.2.6
 - cleaned up how stored procedure execution operated when the user does or does not have execute privs

Modified: branches/5.2/MySql.Data/Provider/Source/CompressedStream.cs
===================================================================
--- branches/5.2/MySql.Data/Provider/Source/CompressedStream.cs	2009-06-16 16:23:20 UTC (rev 1650)
+++ branches/5.2/MySql.Data/Provider/Source/CompressedStream.cs	2009-06-17 18:26:27 UTC (rev 1651)
@@ -22,6 +22,7 @@
 using System.IO;
 using zlib;
 using MySql.Data.MySqlClient.Properties;
+using MySql.Data.Common;
 
 namespace MySql.Data.MySqlClient
 {
@@ -131,8 +132,11 @@
             if (inPos == maxInPos)
             {
                 zInStream = null;
-                inBufferRef.Target = inBuffer;
-                inBuffer = null;
+                if (!Platform.IsMono())
+                {
+                    inBufferRef = new WeakReference(inBuffer, false);
+                    inBuffer = null;
+                }
             }
 
             return countRead;
@@ -165,7 +169,9 @@
 
         private void ReadNextPacket(int len)
         {
-            inBuffer = (byte[])inBufferRef.Target;
+            if (!Platform.IsMono())
+                inBuffer = inBufferRef.Target as byte[];
+
             if (inBuffer == null || inBuffer.Length < len)
                 inBuffer = new byte[len];
             ReadFully(inBuffer, len);

Modified: branches/5.2/MySql.Data/Provider/Source/common/Platform.cs
===================================================================
--- branches/5.2/MySql.Data/Provider/Source/common/Platform.cs	2009-06-16 16:23:20 UTC (rev 1650)
+++ branches/5.2/MySql.Data/Provider/Source/common/Platform.cs	2009-06-17 18:26:27 UTC (rev 1651)
@@ -24,6 +24,9 @@
 {
 	internal class Platform
 	{
+        private static bool inited;
+        private static bool isMono;
+
 		/// <summary>
 		/// By creating a private ctor, we keep the compiler from creating a default ctor
 		/// </summary>
@@ -43,5 +46,18 @@
 			}
 				return false;
 		}
+
+        public static bool IsMono()
+        {
+            if (!inited)
+                Init();
+            return isMono;
+        }
+
+        private static void Init()
+        {
+            Type t = Type.GetType("Mono.Runtime");
+            isMono = t != null;
+        }
 	}
 }

Thread
Connector/NET commit: r1651 - in branches/5.2: . MySql.Data/Provider/Source MySql.Data/Provider/Source/commonrburnett17 Jun