mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-10 00:58:17 +03:00
Bug when deleting host, user and vn objects.
git-svn-id: http://svn.opennebula.org/one/trunk@676 3034c82b-c49b-4eb3-8279-a7acafdc01c0
This commit is contained in:
parent
86f3232024
commit
581f50d600
@ -37,7 +37,7 @@ class PoolObjectSQL : public ObjectSQL
|
||||
{
|
||||
public:
|
||||
|
||||
PoolObjectSQL(int id=-1):oid(id)
|
||||
PoolObjectSQL(int id=-1):oid(id),valid(true)
|
||||
{
|
||||
pthread_mutex_init(&mutex,0);
|
||||
};
|
||||
@ -54,6 +54,24 @@ public:
|
||||
return oid;
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if the object is valid
|
||||
* @return true if object is valid
|
||||
*/
|
||||
const bool& isValid() const
|
||||
{
|
||||
return valid;
|
||||
};
|
||||
|
||||
/**
|
||||
* Set the object valid flag
|
||||
* @param _valid new valid flag
|
||||
*/
|
||||
void set_valid(const bool _valid)
|
||||
{
|
||||
valid = _valid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to lock the object
|
||||
*/
|
||||
@ -74,7 +92,12 @@ protected:
|
||||
/**
|
||||
* The object unique ID
|
||||
*/
|
||||
int oid;
|
||||
int oid;
|
||||
|
||||
/**
|
||||
* The contents ob this object are valid
|
||||
*/
|
||||
bool valid;
|
||||
|
||||
private:
|
||||
|
||||
|
@ -362,18 +362,23 @@ int Host::dump(SqliteDB * db, ostringstream& oss, const string& where)
|
||||
|
||||
int Host::drop(SqliteDB * db)
|
||||
{
|
||||
ostringstream oss;
|
||||
ostringstream oss;
|
||||
int rc;
|
||||
|
||||
// First, drop the template
|
||||
host_template.drop(db);
|
||||
|
||||
// Second, drop the host_shares
|
||||
host_share.drop(db);
|
||||
|
||||
// Third, drop the host itself
|
||||
oss << "DELETE FROM " << table << " WHERE oid=" << oid;
|
||||
|
||||
return db->exec(oss);
|
||||
rc = db->exec(oss);
|
||||
|
||||
if ( rc == 0 )
|
||||
{
|
||||
set_valid(false);
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
@ -166,14 +166,23 @@ PoolObjectSQL * PoolSQL::get(
|
||||
|
||||
if ( index != pool.end() )
|
||||
{
|
||||
if ( olock == true )
|
||||
if ( index->second->isValid() == false )
|
||||
{
|
||||
index->second->lock();
|
||||
objectsql = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
objectsql = index->second;
|
||||
|
||||
if ( olock == true )
|
||||
{
|
||||
objectsql->lock();
|
||||
}
|
||||
}
|
||||
|
||||
unlock();
|
||||
|
||||
return index->second;
|
||||
return objectsql;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -61,6 +61,8 @@ void RequestManager::HostDelete::execute(
|
||||
|
||||
rc = HostDelete::hpool->drop(host);
|
||||
|
||||
host->unlock();
|
||||
|
||||
// All nice, return the host info to the client
|
||||
arrayData.push_back(xmlrpc_c::value_boolean( rc == 0 )); // SUCCESS
|
||||
arrayresult = new xmlrpc_c::value_array(arrayData);
|
||||
|
@ -66,6 +66,8 @@ void RequestManager::UserDelete::execute(
|
||||
}
|
||||
|
||||
rc = UserDelete::upool->drop(user);
|
||||
|
||||
user->unlock();
|
||||
|
||||
if ( rc != 0 )
|
||||
{
|
||||
@ -79,7 +81,7 @@ void RequestManager::UserDelete::execute(
|
||||
arrayresult = new xmlrpc_c::value_array(arrayData);
|
||||
*retval = *arrayresult;
|
||||
|
||||
delete arrayresult; // and get rid of the original
|
||||
delete arrayresult; // and get rid of the original
|
||||
|
||||
return;
|
||||
|
||||
|
@ -65,6 +65,8 @@ void RequestManager::VirtualNetworkDelete::execute(
|
||||
}
|
||||
|
||||
rc = vnpool->drop(vn);
|
||||
|
||||
vn->unlock();
|
||||
|
||||
// All nice, return the host info to the client
|
||||
arrayData.push_back(xmlrpc_c::value_boolean( rc == 0 )); // SUCCESS
|
||||
|
@ -266,11 +266,19 @@ int User::dump(SqliteDB * db, ostringstream& oss, const string& where)
|
||||
|
||||
int User::drop(SqliteDB * db)
|
||||
{
|
||||
ostringstream oss;
|
||||
|
||||
ostringstream oss;
|
||||
int rc;
|
||||
|
||||
oss << "DELETE FROM " << table << " WHERE oid=" << oid;
|
||||
|
||||
return db->exec(oss);
|
||||
rc = db->exec(oss);
|
||||
|
||||
if ( rc == 0 )
|
||||
{
|
||||
set_valid(false);
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
@ -423,7 +423,6 @@ error_null_leases:
|
||||
ose << "Error getting Virtual Network leases nid: " << oid;
|
||||
|
||||
error_leases:
|
||||
vn_template.drop(db);
|
||||
vn_drop(db);
|
||||
|
||||
error_common:
|
||||
@ -477,10 +476,19 @@ int VirtualNetwork::vn_drop(SqliteDB * db)
|
||||
ostringstream oss;
|
||||
int rc;
|
||||
|
||||
vn_template.drop(db);
|
||||
|
||||
leases->drop(db);
|
||||
|
||||
oss << "DELETE FROM " << table << " WHERE OID=" << oid;
|
||||
|
||||
rc = db->exec(oss);
|
||||
|
||||
if ( rc == 0 )
|
||||
{
|
||||
set_valid(false);
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user