mirror of https://github.com/Icinga/icinga2.git
Fix deadlock when querying comments or downtimes through livestatus
fixes #5332
This commit is contained in:
parent
e8cf349451
commit
4a6fddadb8
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue