mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-28 08:04:14 +02:00
Don't allow to modify/create/delete an object concurrently
This commit is contained in:
parent
1b35fe1393
commit
80e8c166ed
@ -6,6 +6,7 @@
|
||||
#include "remote/jsonrpcconnection.hpp"
|
||||
#include "remote/filterutility.hpp"
|
||||
#include "remote/apiaction.hpp"
|
||||
#include "remote/configobjectslock.hpp"
|
||||
#include "remote/zone.hpp"
|
||||
#include "base/configtype.hpp"
|
||||
#include <set>
|
||||
@ -116,6 +117,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);
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "remote/httputility.hpp"
|
||||
#include "remote/filterutility.hpp"
|
||||
#include "remote/apiaction.hpp"
|
||||
#include "remote/configobjectslock.hpp"
|
||||
#include "config/configitem.hpp"
|
||||
#include "base/exception.hpp"
|
||||
#include <boost/algorithm/string/case_conv.hpp>
|
||||
@ -76,6 +77,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.";
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include "remote/httputility.hpp"
|
||||
#include "remote/filterutility.hpp"
|
||||
#include "remote/apiaction.hpp"
|
||||
#include "remote/configobjectslock.hpp"
|
||||
#include "base/exception.hpp"
|
||||
#include <boost/algorithm/string/case_conv.hpp>
|
||||
#include <set>
|
||||
@ -87,6 +88,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 (attrs) {
|
||||
ObjectLock olock(attrs);
|
||||
|
Loading…
x
Reference in New Issue
Block a user