mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-27 07:34:15 +02:00
IcingaDB::NotificationSentToAllUsersHandler(): copy set once, not N*(1+M) times
This commit is contained in:
parent
42f959874e
commit
1e2739aed6
@ -7,6 +7,7 @@
|
|||||||
#include "base/json.hpp"
|
#include "base/json.hpp"
|
||||||
#include "base/logger.hpp"
|
#include "base/logger.hpp"
|
||||||
#include "base/serializer.hpp"
|
#include "base/serializer.hpp"
|
||||||
|
#include "base/shared.hpp"
|
||||||
#include "base/tlsutility.hpp"
|
#include "base/tlsutility.hpp"
|
||||||
#include "base/initialize.hpp"
|
#include "base/initialize.hpp"
|
||||||
#include "base/convert.hpp"
|
#include "base/convert.hpp"
|
||||||
@ -1759,6 +1760,13 @@ void IcingaDB::DowntimeRemovedHandler(const Downtime::Ptr& downtime)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct ATU
|
||||||
|
{
|
||||||
|
String Author;
|
||||||
|
String Text;
|
||||||
|
std::set<User::Ptr> Users;
|
||||||
|
};
|
||||||
|
|
||||||
void IcingaDB::NotificationSentToAllUsersHandler(
|
void IcingaDB::NotificationSentToAllUsersHandler(
|
||||||
const Notification::Ptr& notification, const Checkable::Ptr& checkable, const std::set<User::Ptr>& users,
|
const Notification::Ptr& notification, const Checkable::Ptr& checkable, const std::set<User::Ptr>& users,
|
||||||
NotificationType type, const CheckResult::Ptr& cr, const String& author, const String& text
|
NotificationType type, const CheckResult::Ptr& cr, const String& author, const String& text
|
||||||
@ -1767,11 +1775,11 @@ void IcingaDB::NotificationSentToAllUsersHandler(
|
|||||||
auto rws (ConfigType::GetObjectsByType<IcingaDB>());
|
auto rws (ConfigType::GetObjectsByType<IcingaDB>());
|
||||||
|
|
||||||
if (!rws.empty()) {
|
if (!rws.empty()) {
|
||||||
auto authorAndText (std::make_shared<std::pair<String, String>>(author, text));
|
auto atu (Shared<ATU>::Make(ATU{author, text, users}));
|
||||||
|
|
||||||
for (auto& rw : rws) {
|
for (auto& rw : rws) {
|
||||||
rw->m_WorkQueue.Enqueue([rw, notification, checkable, users, type, cr, authorAndText]() {
|
rw->m_WorkQueue.Enqueue([rw, notification, checkable, atu, type, cr]() {
|
||||||
rw->SendSentNotification(notification, checkable, users, type, cr, authorAndText->first, authorAndText->second);
|
rw->SendSentNotification(notification, checkable, atu->Users, type, cr, atu->Author, atu->Text);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user