List:Commits« Previous MessageNext Message »
From:rburnett Date:December 13 2006 6:56pm
Subject:Connector/NET commit: r498 - branches/1.0/mysqlclient
View as plain text  
Modified:
   branches/1.0/mysqlclient/ProcedureCache.cs
Log:
Bug #23905 Stored procedure usages is not thread safe 

Fixed this by locking on the hashtable syncroot in AddNew.  This will mean that in some
cases a hard query is done for two procs at the same time but this allows me to know do a
lock in the GetProc method which should keep speed high.

Modified: branches/1.0/mysqlclient/ProcedureCache.cs
===================================================================
--- branches/1.0/mysqlclient/ProcedureCache.cs	2006-12-13 17:51:39 UTC (rev 497)
+++ branches/1.0/mysqlclient/ProcedureCache.cs	2006-12-13 17:56:02 UTC (rev 498)
@@ -84,9 +84,15 @@
 				if (procHash.Keys.Count == maxSize)
 					TrimHash();
 				int hash = spName.GetHashCode();
-				procHash.Add(hash, procData);
-				hashQueue.Enqueue(hash);
-			}
+                lock (procHash.SyncRoot)
+                {
+                    if (!procHash.ContainsKey(hash))
+                    {
+                        procHash[hash] = procData;
+                        hashQueue.Enqueue(hash);
+                    }
+                }
+            }
 			return procData;
 		}
 

Thread
Connector/NET commit: r498 - branches/1.0/mysqlclientrburnett13 Dec