I find the following piece of code in DBManager in Roxen:
Sql.Sql sql_cache_get(string db, string url, void|mapping sessiondbs,
void|string charset)
{
Thread.MutexKey key = roxenloader.sq_cache_lock();
Sql.Sql res = roxenloader.sq_cache_get(db, sessiondbs, charset);
if (res) return res;
// Release the lock during the call to get_sql_handler(),
// since it may take quite a bit of time...
destruct(key);
if (res = get_sql_handler(url)) {
// Now we need the lock again...
key = roxenloader.sq_cache_lock();
res = roxenloader.sq_cache_set(db, res, sessiondbs, charset);
// Fool the optimizer so that key is not released prematurely
if( res )
return res;
}
}
Can someone explain why the if(res) return res; actually fools
the optimiser into not releasing "key" early?
--
Sincerely,
Stephen R. van den Berg.
E-mails should be like a lady's skirt:
Long enough to cover the subject, and short enough to be interesting.
|