From 540e63c157f6855247e3183205b7f05476e4783b Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Thu, 11 Jul 2013 08:58:11 +0200 Subject: [PATCH] Make sure new comments/downtimes are added to the ID cache right away. --- components/livestatus/commentstable.cpp | 3 ++- components/livestatus/downtimestable.cpp | 3 ++- lib/icinga/service-comment.cpp | 5 +++++ lib/icinga/service-downtime.cpp | 5 +++++ 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/components/livestatus/commentstable.cpp b/components/livestatus/commentstable.cpp index 05c077bf9..f551d180e 100644 --- a/components/livestatus/commentstable.cpp +++ b/components/livestatus/commentstable.cpp @@ -69,7 +69,8 @@ void CommentsTable::FetchRows(const AddRowFunction& addRowFn) String id; BOOST_FOREACH(boost::tie(id, boost::tuples::ignore), comments) { - addRowFn(id); + if (Service::GetOwnerByCommentID(id) == service) + addRowFn(id); } } } diff --git a/components/livestatus/downtimestable.cpp b/components/livestatus/downtimestable.cpp index f8e6650c9..2222f647b 100644 --- a/components/livestatus/downtimestable.cpp +++ b/components/livestatus/downtimestable.cpp @@ -69,7 +69,8 @@ void DowntimesTable::FetchRows(const AddRowFunction& addRowFn) String id; BOOST_FOREACH(boost::tie(id, boost::tuples::ignore), downtimes) { - addRowFn(id); + if (Service::GetOwnerByDowntimeID(id) == service) + addRowFn(id); } } } diff --git a/lib/icinga/service-comment.cpp b/lib/icinga/service-comment.cpp index 972b71c8d..46fe4f35a 100644 --- a/lib/icinga/service-comment.cpp +++ b/lib/icinga/service-comment.cpp @@ -90,6 +90,11 @@ String Service::AddComment(CommentType entryType, const String& author, Touch("comments"); } + { + boost::mutex::scoped_lock lock(l_CommentMutex); + l_CommentsCache[id] = GetSelf(); + } + return id; } diff --git a/lib/icinga/service-downtime.cpp b/lib/icinga/service-downtime.cpp index c40ef94ce..87059158a 100644 --- a/lib/icinga/service-downtime.cpp +++ b/lib/icinga/service-downtime.cpp @@ -126,6 +126,11 @@ String Service::AddDowntime(const String& author, const String& comment, (void) AddComment(CommentDowntime, author, comment, endTime); + { + boost::mutex::scoped_lock lock(l_DowntimeMutex); + l_DowntimesCache[id] = GetSelf(); + } + return id; } -- 2.40.0