Merge pull request #8780 from Icinga/bugfix/concurent-notification-send-and-delete-2.11

Fix crash when notifications are sent while the notification object is deleted (2.11)
This commit is contained in:
Alexander Aleksandrovič Klimov 2021-05-26 13:36:18 +02:00 committed by GitHub
commit 031f379051
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -398,7 +398,11 @@ void Notification::BeginExecuteNotification(NotificationType type, const CheckRe
<< "Sending " << (reminder ? "reminder " : "") << "'" << NotificationTypeToString(type) << "' notification '"
<< notificationName << "' for user '" << userName << "'";
Utility::QueueAsyncCallback(std::bind(&Notification::ExecuteNotificationHelper, this, type, user, cr, force, author, text));
// Explicitly use Notification::Ptr to keep the reference counted while the callback is active
Notification::Ptr notification (this);
Utility::QueueAsyncCallback([notification, type, user, cr, force, author, text]() {
notification->ExecuteNotificationHelper(type, user, cr, force, author, text);
});
/* collect all notified users */
allNotifiedUsers.insert(user);