From: Date: December 13 2006 6:56pm Subject: Connector/NET commit: r498 - branches/1.0/mysqlclient List-Archive: http://lists.mysql.com/commits/16902 X-Bug: 23905 Message-Id: <200612131756.kBDHu31Y005604@bk-internal.mysql.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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; }