1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-01-12 09:17:41 +03:00

bug: Solve search by name when deleting and creating resources with the same name

This commit is contained in:
Ruben S. Montero 2011-11-26 23:49:59 +01:00
parent e3d1ce2cd3
commit c046ad0d5a

View File

@ -198,6 +198,8 @@ PoolObjectSQL * PoolSQL::get(
}
else
{
map<string,PoolObjectSQL *>::iterator name_index;
objectsql = create();
objectsql->oid = oid;
@ -214,6 +216,19 @@ PoolObjectSQL * PoolSQL::get(
}
string okey = key(objectsql->name,objectsql->uid);
name_index = name_pool.find(okey);
if ( name_index != name_pool.end() )
{
name_index->second->lock();
PoolObjectSQL * tmp_ptr = name_index->second;
name_pool.erase(okey);
pool.erase(tmp_ptr->oid);
delete tmp_ptr;
}
pool.insert(make_pair(objectsql->oid,objectsql));
name_pool.insert(make_pair(okey, objectsql));