Merge pull request #9924 from ymartin-ovh/pr-9916

Fix `/v1/actions/` deadlock & nullptr dereference
This commit is contained in:
Julian Brost 2025-06-06 15:15:51 +02:00 committed by GitHub
commit 4d9e9e7ed6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 5 additions and 8 deletions

View File

@ -642,9 +642,6 @@ bool ConfigItem::CommitItems(const ActivationContext::Ptr& context, WorkQueue& u
bool ConfigItem::ActivateItems(const std::vector<ConfigItem::Ptr>& newItems, bool runtimeCreated,
bool mainConfigActivation, bool withModAttrs, const Value& cookie)
{
static std::mutex mtx;
std::unique_lock<std::mutex> lock(mtx);
if (withModAttrs) {
/* restore modified attributes */
if (Utility::PathExists(Configuration::ModAttrPath)) {

View File

@ -315,11 +315,11 @@ Dictionary::Ptr ApiActions::AddComment(const ConfigObject::Ptr& object,
return ApiActions::CreateResult(503, "Icinga is reloading.");
}
String commentName = Comment::AddComment(checkable, CommentUser,
Comment::Ptr comment = Comment::AddComment(checkable, CommentUser,
HttpUtility::GetLastParameter(params, "author"),
HttpUtility::GetLastParameter(params, "comment"), false, timestamp);
Comment::Ptr comment = Comment::GetByName(commentName);
String commentName = comment->GetName();
Dictionary::Ptr additional = new Dictionary({
{ "name", commentName },

View File

@ -130,7 +130,7 @@ int Comment::GetNextCommentID()
return l_NextCommentID;
}
String Comment::AddComment(const Checkable::Ptr& checkable, CommentType entryType, const String& author,
Comment::Ptr Comment::AddComment(const Checkable::Ptr& checkable, CommentType entryType, const String& author,
const String& text, bool persistent, double expireTime, bool sticky, const String& id, const MessageOrigin::Ptr& origin)
{
String fullName;
@ -184,7 +184,7 @@ String Comment::AddComment(const Checkable::Ptr& checkable, CommentType entryTyp
Log(LogNotice, "Comment")
<< "Added comment '" << comment->GetName() << "'.";
return fullName;
return comment;
}
void Comment::RemoveComment(const String& id, bool removedManually, const String& removedBy,

View File

@ -34,7 +34,7 @@ public:
static int GetNextCommentID();
static String AddComment(const intrusive_ptr<Checkable>& checkable, CommentType entryType,
static Ptr AddComment(const intrusive_ptr<Checkable>& checkable, CommentType entryType,
const String& author, const String& text, bool persistent, double expireTime, bool sticky = false,
const String& id = String(), const MessageOrigin::Ptr& origin = nullptr);