mirror of https://github.com/Icinga/icinga2.git
Don't allow to modify/create/delete an object concurrently
This commit is contained in:
parent
099f664ce6
commit
546dea95a2
|
@ -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);
|
||||
|
|
|
@ -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.";
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue