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

fix dead-lock when deleting a host

This commit is contained in:
Ruben S. Montero 2013-10-31 14:59:37 +01:00
parent 8c92a42242
commit ba92116496
4 changed files with 33 additions and 34 deletions

View File

@ -235,16 +235,14 @@ error_common:
int HostPool::drop(int hid, string& error_msg)
{
Host * host;
host = get(hid,true);
Host * host = get(hid,true);
if (host == 0)
{
ostringstream oss;
oss << "Could not get host " << hid;
error_msg = oss.str();
return -1;
}

View File

@ -176,36 +176,30 @@ void InformationManager::do_action(const string &action, void * arg)
void InformationManager::stop_monitor(int hid)
{
Host * host;
const InformationManagerDriver * imd;
ostringstream oss;
host = hpool->get(hid,true);
Host * host = hpool->get(hid,true);
if (host == 0) //Already deleted silently return
{
return;
}
imd = get(host->get_im_mad());
const InformationManagerDriver * imd = get(host->get_im_mad());
if (imd == 0)
if (imd == 0) //No IM Driver to call, delete host.
{
oss.str("");
oss << "Could not find information driver " << host->get_im_mad();
NebulaLog::log("InM",Log::ERROR,oss);
string error_str;
host->unlock();
return;
hpool->drop(host, error_str);
if (!error_str.empty())
{
NebulaLog::log("InM", Log::ERROR, error_str);
}
}
else
{
imd->stop_monitor(hid, host->get_name());
}
host->disable();
imd->stop_monitor(hid, host->get_name());
hpool->update(host);
host->unlock();
}

View File

@ -295,13 +295,6 @@ void InformationManagerDriver::protocol(const string& message) const
int rc;
string error;
host = hpool->get(id,true);
if ( host == 0 )
{
goto error_host;
}
if (result != "SUCCESS")
{
ostringstream oss;
@ -315,8 +308,6 @@ void InformationManagerDriver::protocol(const string& message) const
rc = hpool->drop(id, error);
host->unlock();
if (rc != 0)
{
ostringstream oss;

View File

@ -146,9 +146,25 @@ int RequestManagerDelete::drop(
int HostDelete::drop(int oid, PoolObjectSQL * object, string& error_msg)
{
Nebula& nd = Nebula::instance();
Nebula& nd = Nebula::instance();
InformationManager * im = nd.get_im();
HostPool * hpool = nd.get_hpool();
Host* host = static_cast<Host *>(object);
if ( host->get_share_running_vms() > 0 )
{
error_msg = "Can not remove a host with running VMs";
return -1;
}
host->disable();
hpool->update(host);
host->unlock();
im->trigger(InformationManager::STOPMONITOR, oid);
return 0;