1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-22 18:50:08 +03:00

Bug #721: Make the PoolSQL cache be aware that an invalid cached object may have the same name as a non-cached valid object.

This commit is contained in:
Carlos Martín 2011-07-27 18:19:17 +02:00
parent 11214a6758
commit 033b96dfa9

View File

@ -185,6 +185,11 @@ PoolObjectSQL * PoolSQL::get(
if ( olock == true )
{
objectsql->lock();
if ( objectsql->isValid() == false )
{
objectsql = 0;
}
}
}
@ -246,19 +251,17 @@ PoolObjectSQL * PoolSQL::get(const string& name, int ouid, bool olock)
index = name_pool.find(key(name,ouid));
if ( index != name_pool.end() )
if ( index != name_pool.end() && index->second->isValid() == true )
{
if ( index->second->isValid() == false )
{
objectsql = 0;
}
else
{
objectsql = index->second;
objectsql = index->second;
if ( olock == true )
if ( olock == true )
{
objectsql->lock();
if ( objectsql->isValid() == false )
{
objectsql->lock();
objectsql = 0;
}
}
@ -281,6 +284,19 @@ PoolObjectSQL * PoolSQL::get(const string& name, int ouid, bool olock)
return 0;
}
if ( index != name_pool.end() && index->second->isValid() == false )
{
index->second->lock();
PoolObjectSQL * tmp_ptr = index->second;
string tmp_okey = key(tmp_ptr->name,tmp_ptr->uid);
pool.erase(tmp_ptr->oid);
name_pool.erase(tmp_okey);
delete tmp_ptr;
}
string okey = key(objectsql->name,objectsql->uid);
pool.insert(make_pair(objectsql->oid, objectsql));
@ -323,7 +339,7 @@ void PoolSQL::replace()
if ( index == pool.end())
{
oid_queue.pop();
break;
continue;
}
rc = pthread_mutex_trylock(&(index->second->mutex));