mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-23 13:45:04 +02:00
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;
|
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)) {
|
if (!ConfigObjectUtility::CreateObject(type, name, config, errors, diagnosticInformation)) {
|
||||||
result1->Set("errors", errors);
|
result1->Set("errors", errors);
|
||||||
result1->Set("code", 500);
|
result1->Set("code", 500);
|
||||||
|
@ -84,6 +84,9 @@ bool DeleteObjectHandler::HandleRequest(
|
|||||||
Array::Ptr errors = new Array();
|
Array::Ptr errors = new Array();
|
||||||
Array::Ptr diagnosticInformation = 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)) {
|
if (!ConfigObjectUtility::DeleteObject(obj, cascade, errors, diagnosticInformation)) {
|
||||||
code = 500;
|
code = 500;
|
||||||
status = "Object could not be deleted.";
|
status = "Object could not be deleted.";
|
||||||
|
@ -112,6 +112,9 @@ bool ModifyObjectHandler::HandleRequest(
|
|||||||
|
|
||||||
String key;
|
String key;
|
||||||
|
|
||||||
|
// Lock the object name of the given type to prevent from being modified/deleted concurrently.
|
||||||
|
ObjectNameLock objectNameLock(type, obj->GetName());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (restoreAttrs) {
|
if (restoreAttrs) {
|
||||||
ObjectLock oLock (restoreAttrs);
|
ObjectLock oLock (restoreAttrs);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user