Don't allow to modify/create/delete an object concurrently

This commit is contained in:
Yonas Habteab 2024-03-11 12:34:14 +01:00
parent 099f664ce6
commit 546dea95a2
3 changed files with 9 additions and 0 deletions

View File

@ -124,6 +124,9 @@ bool CreateObjectHandler::HandleRequest(
return true;
}
// Lock the object name of the given type to prevent from being created concurrently.
ObjectNameLock objectNameLock(type, name);
if (!ConfigObjectUtility::CreateObject(type, name, config, errors, diagnosticInformation)) {
result1->Set("errors", errors);
result1->Set("code", 500);

View File

@ -84,6 +84,9 @@ bool DeleteObjectHandler::HandleRequest(
Array::Ptr errors = new Array();
Array::Ptr diagnosticInformation = new Array();
// Lock the object name of the given type to prevent from being modified/deleted concurrently.
ObjectNameLock objectNameLock(type, obj->GetName());
if (!ConfigObjectUtility::DeleteObject(obj, cascade, errors, diagnosticInformation)) {
code = 500;
status = "Object could not be deleted.";

View File

@ -112,6 +112,9 @@ bool ModifyObjectHandler::HandleRequest(
String key;
// Lock the object name of the given type to prevent from being modified/deleted concurrently.
ObjectNameLock objectNameLock(type, obj->GetName());
try {
if (restoreAttrs) {
ObjectLock oLock (restoreAttrs);