From: Johannes Meyer Date: Mon, 16 Dec 2013 13:14:01 +0000 (+0100) Subject: Fix deadlock when querying comments or downtimes through livestatus X-Git-Tag: v0.0.6~26 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4a6fddadb81b6f8e083fa30a96bbe1d7998ce2cd;p=icinga2 Fix deadlock when querying comments or downtimes through livestatus fixes #5332 --- diff --git a/components/livestatus/commentstable.cpp b/components/livestatus/commentstable.cpp index 21250792b..c77ea587d 100644 --- a/components/livestatus/commentstable.cpp +++ b/components/livestatus/commentstable.cpp @@ -63,21 +63,23 @@ void CommentsTable::FetchRows(const AddRowFunction& addRowFn) ObjectLock olock(comments); String id; - BOOST_FOREACH(boost::tie(id, boost::tuples::ignore), comments) { + Comment::Ptr comment; + BOOST_FOREACH(boost::tie(id, comment), comments) { if (Service::GetOwnerByCommentID(id) == service) - addRowFn(id); + addRowFn(comment); } } } Object::Ptr CommentsTable::ServiceAccessor(const Value& row, const Column::ObjectAccessor& parentObjectAccessor) { - return Service::GetOwnerByCommentID(row); + Comment::Ptr comment = static_cast(row); + return Service::GetOwnerByCommentID(comment->GetId()); } Value CommentsTable::AuthorAccessor(const Value& row) { - Comment::Ptr comment = Service::GetCommentByID(row); + Comment::Ptr comment = static_cast(row); if (!comment) return Empty; @@ -87,7 +89,7 @@ Value CommentsTable::AuthorAccessor(const Value& row) Value CommentsTable::CommentAccessor(const Value& row) { - Comment::Ptr comment = Service::GetCommentByID(row); + Comment::Ptr comment = static_cast(row); if (!comment) return Empty; @@ -97,7 +99,7 @@ Value CommentsTable::CommentAccessor(const Value& row) Value CommentsTable::IdAccessor(const Value& row) { - Comment::Ptr comment = Service::GetCommentByID(row); + Comment::Ptr comment = static_cast(row); if (!comment) return Empty; @@ -107,7 +109,7 @@ Value CommentsTable::IdAccessor(const Value& row) Value CommentsTable::EntryTimeAccessor(const Value& row) { - Comment::Ptr comment = Service::GetCommentByID(row); + Comment::Ptr comment = static_cast(row); if (!comment) return Empty; @@ -137,7 +139,7 @@ Value CommentsTable::IsServiceAccessor(const Value& row) Value CommentsTable::EntryTypeAccessor(const Value& row) { - Comment::Ptr comment = Service::GetCommentByID(row); + Comment::Ptr comment = static_cast(row); if (!comment) return Empty; @@ -147,7 +149,7 @@ Value CommentsTable::EntryTypeAccessor(const Value& row) Value CommentsTable::ExpiresAccessor(const Value& row) { - Comment::Ptr comment = Service::GetCommentByID(row); + Comment::Ptr comment = static_cast(row); if (!comment) return Empty; @@ -157,7 +159,7 @@ Value CommentsTable::ExpiresAccessor(const Value& row) Value CommentsTable::ExpireTimeAccessor(const Value& row) { - Comment::Ptr comment = Service::GetCommentByID(row); + Comment::Ptr comment = static_cast(row); if (!comment) return Empty; diff --git a/components/livestatus/downtimestable.cpp b/components/livestatus/downtimestable.cpp index fa182b35e..2f6f3df4a 100644 --- a/components/livestatus/downtimestable.cpp +++ b/components/livestatus/downtimestable.cpp @@ -63,91 +63,94 @@ void DowntimesTable::FetchRows(const AddRowFunction& addRowFn) ObjectLock olock(downtimes); String id; - BOOST_FOREACH(boost::tie(id, boost::tuples::ignore), downtimes) { + Downtime::Ptr downtime; + BOOST_FOREACH(boost::tie(id, downtime), downtimes) { if (Service::GetOwnerByDowntimeID(id) == service) - addRowFn(id); + addRowFn(downtime); } } } Object::Ptr DowntimesTable::ServiceAccessor(const Value& row, const Column::ObjectAccessor& parentObjectAccessor) { - return Service::GetOwnerByDowntimeID(row); + Downtime::Ptr downtime = static_cast(row); + return Service::GetOwnerByDowntimeID(downtime->GetId()); } Value DowntimesTable::AuthorAccessor(const Value& row) { - Downtime::Ptr downtime = Service::GetDowntimeByID(row); + Downtime::Ptr downtime = static_cast(row); return downtime->GetAuthor(); } Value DowntimesTable::CommentAccessor(const Value& row) { - Downtime::Ptr downtime = Service::GetDowntimeByID(row); + Downtime::Ptr downtime = static_cast(row); return downtime->GetComment(); } Value DowntimesTable::IdAccessor(const Value& row) { - Downtime::Ptr downtime = Service::GetDowntimeByID(row); + Downtime::Ptr downtime = static_cast(row); return downtime->GetLegacyId(); } Value DowntimesTable::EntryTimeAccessor(const Value& row) { - Downtime::Ptr downtime = Service::GetDowntimeByID(row); + Downtime::Ptr downtime = static_cast(row); return static_cast(downtime->GetEntryTime()); } Value DowntimesTable::TypeAccessor(const Value& row) { - Downtime::Ptr downtime = Service::GetDowntimeByID(row); + Downtime::Ptr downtime = static_cast(row); // 1 .. active, 0 .. pending return (downtime->IsActive() ? 1 : 0); } Value DowntimesTable::IsServiceAccessor(const Value& row) { - Service::Ptr svc = Service::GetOwnerByDowntimeID(row); + Downtime::Ptr downtime = static_cast(row); + Service::Ptr svc = Service::GetOwnerByDowntimeID(downtime->GetId()); return (svc->IsHostCheck() ? 0 : 1); } Value DowntimesTable::StartTimeAccessor(const Value& row) { - Downtime::Ptr downtime = Service::GetDowntimeByID(row); + Downtime::Ptr downtime = static_cast(row); return static_cast(downtime->GetStartTime()); } Value DowntimesTable::EndTimeAccessor(const Value& row) { - Downtime::Ptr downtime = Service::GetDowntimeByID(row); + Downtime::Ptr downtime = static_cast(row); return static_cast(downtime->GetEndTime()); } Value DowntimesTable::FixedAccessor(const Value& row) { - Downtime::Ptr downtime = Service::GetDowntimeByID(row); + Downtime::Ptr downtime = static_cast(row); return downtime->GetFixed(); } Value DowntimesTable::DurationAccessor(const Value& row) { - Downtime::Ptr downtime = Service::GetDowntimeByID(row); + Downtime::Ptr downtime = static_cast(row); return downtime->GetDuration(); } Value DowntimesTable::TriggeredByAccessor(const Value& row) { - Downtime::Ptr downtime = Service::GetDowntimeByID(row); + Downtime::Ptr downtime = static_cast(row); return downtime->GetTriggeredBy(); }