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

feature #200: Prevents dead-lock and removes some blank lines

This commit is contained in:
Ruben S. Montero 2010-07-08 01:38:07 +02:00
parent 0139994dcf
commit 8a9d39a85c
3 changed files with 52 additions and 55 deletions

View File

@ -31,7 +31,7 @@ void RequestManager::ImageDelete::execute(
int iid;
int uid;
int rc;
Image * image;
ostringstream oss;
@ -53,17 +53,17 @@ void RequestManager::ImageDelete::execute(
{
goto error_authenticate;
}
uid = rc;
// Get image from the ImagePool
image = ImageDelete::ipool->get(iid,true);
if ( image == 0 )
{
goto error_image_get;
image = ImageDelete::ipool->get(iid,true);
if ( image == 0 )
{
goto error_image_get;
}
if ( uid != 0 && uid != image->get_uid() )
{
goto error_authorization;
@ -76,7 +76,7 @@ void RequestManager::ImageDelete::execute(
goto error_delete;
}
image->unlock();
arrayData.push_back(xmlrpc_c::value_boolean(true));
@ -93,17 +93,19 @@ void RequestManager::ImageDelete::execute(
error_authenticate:
oss << "User not authenticated, aborting ImageDelete call.";
goto error_common;
error_image_get:
oss << "Error getting image with ID = " << iid;
oss << "Error getting image with ID = " << iid;
goto error_common;
error_authorization:
oss << "User not authorized to delete image, aborting ImageDelete call.";
image->unlock();
goto error_common;
error_delete:
oss << "Cannot delete image, VMs might be running on it.";
image->unlock();
goto error_common;
error_common:

View File

@ -32,7 +32,7 @@ void RequestManager::ImageRemoveAttribute::execute(
int iid;
int uid;
int rc;
Image * image;
ostringstream oss;
@ -45,7 +45,7 @@ void RequestManager::ImageRemoveAttribute::execute(
session = xmlrpc_c::value_string(paramList.getString(0));
iid = xmlrpc_c::value_int (paramList.getInt(1));
name = xmlrpc_c::value_string(paramList.getString(2));
name = xmlrpc_c::value_string(paramList.getString(2));
// First, we need to authenticate the user
rc = ImageRemoveAttribute::upool->authenticate(session);
@ -54,18 +54,18 @@ void RequestManager::ImageRemoveAttribute::execute(
{
goto error_authenticate;
}
uid = rc;
// Get image from the ImagePool
image = ImageRemoveAttribute::ipool->get(iid,true);
if ( image == 0 )
{
goto error_image_get;
image = ImageRemoveAttribute::ipool->get(iid,true);
if ( image == 0 )
{
goto error_image_get;
}
if ( uid != 0 && uid != image->get_uid() )
{
goto error_authorization;
@ -76,9 +76,8 @@ void RequestManager::ImageRemoveAttribute::execute(
if ( rc < 0 )
{
goto error_remove_attribute;
}
image->unlock();
arrayData.push_back(xmlrpc_c::value_boolean(true));
@ -95,19 +94,19 @@ void RequestManager::ImageRemoveAttribute::execute(
error_authenticate:
oss << "[ImageRemoveAttribute] User not authenticated, aborting call.";
goto error_common;
error_image_get:
oss << "[ImageRemoveAttribute] Error getting image with ID = " << iid;
oss << "[ImageRemoveAttribute] Error getting image with ID = " << iid;
goto error_common;
error_authorization:
oss << "[ImageRemoveAttribute] User not authorized to remove image" <<
oss << "[ImageRemoveAttribute] User not authorized to remove image" <<
" attributes aborting call.";
image->unlock();
goto error_common;
error_remove_attribute:
oss << "[ImageRemoveAttribute] Cannot remove attribute with name = "
oss << "[ImageRemoveAttribute] Cannot remove attribute with name = "
<< name << " for image [" << iid << "]";
image->unlock();
goto error_common;

View File

@ -33,7 +33,7 @@ void RequestManager::ImageUpdate::execute(
string name;
string value;
int rc;
Image * image;
ostringstream oss;
@ -46,10 +46,8 @@ void RequestManager::ImageUpdate::execute(
session = xmlrpc_c::value_string(paramList.getString(0));
iid = xmlrpc_c::value_int (paramList.getInt(1));
name = xmlrpc_c::value_string(paramList.getString(2));
value = xmlrpc_c::value_string(paramList.getString(3));
name = xmlrpc_c::value_string(paramList.getString(2));
value = xmlrpc_c::value_string(paramList.getString(3));
// First, we need to authenticate the user
rc = ImageUpdate::upool->authenticate(session);
@ -58,33 +56,31 @@ void RequestManager::ImageUpdate::execute(
{
goto error_authenticate;
}
uid = rc;
// Get image from the ImagePool
image = ImageUpdate::ipool->get(iid,true);
if ( image == 0 )
{
goto error_image_get;
image = ImageUpdate::ipool->get(iid,true);
if ( image == 0 )
{
goto error_image_get;
}
if ( uid != 0 && uid != image->get_uid() )
{
goto error_authorization;
}
// This will perform the update on the DB as well,
// This will perform the update on the DB as well,
// so no need to do it manually
rc = ImageUpdate::ipool->replace_attribute(image, name, value);
if ( rc < 0 )
{
goto error_update;
}
image->unlock();
arrayData.push_back(xmlrpc_c::value_boolean(true));
@ -101,17 +97,17 @@ void RequestManager::ImageUpdate::execute(
error_authenticate:
oss << "User not authenticated, aborting ImageUpdate call.";
goto error_common;
error_image_get:
oss << "Error getting image with ID = " << iid;
oss << "Error getting image with ID = " << iid;
goto error_common;
error_authorization:
oss << "User not authorized to modify image attributes " <<
oss << "User not authorized to modify image attributes " <<
", aborting ImageUpdate call.";
image->unlock();
goto error_common;
error_update:
oss << "Cannot modify image [" << iid << "] attribute with name = " << name;
image->unlock();