Modified:
trunk/CHANGES
trunk/mysqlclient/core/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: trunk/CHANGES
===================================================================
--- trunk/CHANGES 2006-12-13 16:46:21 UTC (rev 496)
+++ trunk/CHANGES 2006-12-13 17:51:39 UTC (rev 497)
@@ -5,6 +5,7 @@
Bug #23687 Deleting a connection to a disconnected server causes a failed assertion
Bug #24565 Inferring DbType fails when reusing commands and the first time the value is
nul
Bug #24661 mysql-connector-net-5.0.2-beta Driver.IsTooOld() Error....
+ Bug #23905 Stored procedure usages is not thread safe
Other changes
-------------
Modified: trunk/mysqlclient/core/ProcedureCache.cs
===================================================================
--- trunk/mysqlclient/core/ProcedureCache.cs 2006-12-13 16:46:21 UTC (rev 496)
+++ trunk/mysqlclient/core/ProcedureCache.cs 2006-12-13 17:51:39 UTC (rev 497)
@@ -55,22 +55,24 @@
public DataSet GetProcedure(MySqlConnection conn, string spName)
{
int hash = spName.GetHashCode();
- DataSet ds = (DataSet)procHash[hash];
- if (ds == null)
- {
- ds = AddNew(conn, spName);
- conn.PerfMonitor.AddHardProcedureQuery();
- if (conn.Settings.Logging)
- Logger.LogInformation(String.Format(
- Resources.HardProcQuery, spName));
- }
- else
- {
- conn.PerfMonitor.AddSoftProcedureQuery();
- if (conn.Settings.Logging)
- Logger.LogInformation(String.Format(
- Resources.SoftProcQuery, spName));
- }
+ DataSet ds = null;
+
+ ds = (DataSet)procHash[hash];
+ if (ds == null)
+ {
+ ds = AddNew(conn, spName);
+ conn.PerfMonitor.AddHardProcedureQuery();
+ if (conn.Settings.Logging)
+ Logger.LogInformation(String.Format(
+ Resources.HardProcQuery, spName));
+ }
+ else
+ {
+ conn.PerfMonitor.AddSoftProcedureQuery();
+ if (conn.Settings.Logging)
+ Logger.LogInformation(String.Format(
+ Resources.SoftProcQuery, spName));
+ }
return ds;
}
@@ -82,8 +84,14 @@
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: r497 - in trunk: . mysqlclient/core | rburnett | 13 Dec |