[icinga-checkins] icinga.org: icinga2/master: Make sure new comments/ downtimes are added to the ID cache right away.

git at icinga.org git at icinga.org
Thu Jul 11 09:40:59 CEST 2013


Module: icinga2
Branch: master
Commit: 540e63c157f6855247e3183205b7f05476e4783b
URL:    https://git.icinga.org/?p=icinga2.git;a=commit;h=540e63c157f6855247e3183205b7f05476e4783b

Author: Gunnar Beutner <gunnar.beutner at netways.de>
Date:   Thu Jul 11 08:58:11 2013 +0200

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 05c077b..f551d18 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 f8e6650..2222f64 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 972b71c..46fe4f3 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 c40ef94..8705915 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;
 }
 





More information about the icinga-checkins mailing list