From: Gunnar Beutner Date: Thu, 11 Jul 2013 06:58:11 +0000 (+0200) Subject: Make sure new comments/downtimes are added to the ID cache right away. X-Git-Tag: v0.0.3~865 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=540e63c157f6855247e3183205b7f05476e4783b;p=icinga2 Make sure new comments/downtimes are added to the ID cache right away. --- 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; }