]> granicus.if.org Git - icinga2/commitdiff
Fix deadlock when querying comments or downtimes through livestatus
authorJohannes Meyer <johannes.meyer@netways.de>
Mon, 16 Dec 2013 13:14:01 +0000 (14:14 +0100)
committerJohannes Meyer <johannes.meyer@netways.de>
Mon, 16 Dec 2013 13:14:01 +0000 (14:14 +0100)
fixes #5332

components/livestatus/commentstable.cpp
components/livestatus/downtimestable.cpp

index 21250792b178e292b853d54bf74a2e3ceb025f6a..c77ea587d156d21adca80f3584391081b548b80d 100644 (file)
@@ -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<Comment::Ptr>(row);
+       return Service::GetOwnerByCommentID(comment->GetId());
 }
 
 Value CommentsTable::AuthorAccessor(const Value& row)
 {
-       Comment::Ptr comment = Service::GetCommentByID(row);
+       Comment::Ptr comment = static_cast<Comment::Ptr>(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<Comment::Ptr>(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<Comment::Ptr>(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<Comment::Ptr>(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<Comment::Ptr>(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<Comment::Ptr>(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<Comment::Ptr>(row);
 
        if (!comment)
                return Empty;
index fa182b35e78e561c1316163255e4e598f7010003..2f6f3df4a4da8e7fd799c84925730fd71bf3c358 100644 (file)
@@ -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<Downtime::Ptr>(row);
+       return Service::GetOwnerByDowntimeID(downtime->GetId());
 }
 
 Value DowntimesTable::AuthorAccessor(const Value& row)
 {
-       Downtime::Ptr downtime = Service::GetDowntimeByID(row);
+       Downtime::Ptr downtime = static_cast<Downtime::Ptr>(row);
 
        return downtime->GetAuthor();
 }
 
 Value DowntimesTable::CommentAccessor(const Value& row)
 {
-       Downtime::Ptr downtime = Service::GetDowntimeByID(row);
+       Downtime::Ptr downtime = static_cast<Downtime::Ptr>(row);
 
        return downtime->GetComment();
 }
 
 Value DowntimesTable::IdAccessor(const Value& row)
 {
-       Downtime::Ptr downtime = Service::GetDowntimeByID(row);
+       Downtime::Ptr downtime = static_cast<Downtime::Ptr>(row);
 
        return downtime->GetLegacyId();
 }
 
 Value DowntimesTable::EntryTimeAccessor(const Value& row)
 {
-       Downtime::Ptr downtime = Service::GetDowntimeByID(row);
+       Downtime::Ptr downtime = static_cast<Downtime::Ptr>(row);
 
        return static_cast<int>(downtime->GetEntryTime());
 }
 
 Value DowntimesTable::TypeAccessor(const Value& row)
 {
-       Downtime::Ptr downtime = Service::GetDowntimeByID(row);
+       Downtime::Ptr downtime = static_cast<Downtime::Ptr>(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<Downtime::Ptr>(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<Downtime::Ptr>(row);
 
        return static_cast<int>(downtime->GetStartTime());
 }
 
 Value DowntimesTable::EndTimeAccessor(const Value& row)
 {
-       Downtime::Ptr downtime = Service::GetDowntimeByID(row);
+       Downtime::Ptr downtime = static_cast<Downtime::Ptr>(row);
 
        return static_cast<int>(downtime->GetEndTime());
 }
 
 Value DowntimesTable::FixedAccessor(const Value& row)
 {
-       Downtime::Ptr downtime = Service::GetDowntimeByID(row);
+       Downtime::Ptr downtime = static_cast<Downtime::Ptr>(row);
 
        return downtime->GetFixed();
 }
 
 Value DowntimesTable::DurationAccessor(const Value& row)
 {
-       Downtime::Ptr downtime = Service::GetDowntimeByID(row);
+       Downtime::Ptr downtime = static_cast<Downtime::Ptr>(row);
 
        return downtime->GetDuration();
 }
 
 Value DowntimesTable::TriggeredByAccessor(const Value& row)
 {
-       Downtime::Ptr downtime = Service::GetDowntimeByID(row);
+       Downtime::Ptr downtime = static_cast<Downtime::Ptr>(row);
 
        return downtime->GetTriggeredBy();
 }