abrt/0002-abrt-journal-call-sd_journal_get_fd-right-after-sd_j.patch
Michal Srb 534292e248 abrt-journal: call sd_journal_get_fd() right after sd_journal_open()
Resolves: rhbz#2128662

Signed-off-by: Michal Srb <michal@redhat.com>
2022-10-12 09:43:01 +02:00

66 lines
1.8 KiB
Diff

From 4ebe2699287844d2766f87062c48d8953b292bfe Mon Sep 17 00:00:00 2001
From: Michal Srb <michal@redhat.com>
Date: Tue, 11 Oct 2022 22:41:33 +0200
Subject: [PATCH] abrt-journal: call sd_journal_get_fd() right after
sd_journal_open()
See: rhbz#2128662
Under certain circumstances, abrt-dump-journal can be running,
but not receiving any event notifications from journal.
The culprit of the issue seems to be the delayed call
to sd_journal_get_fd(), as discussed in various
issues and pull-requests in other projects.
See for example [1], [2], or [3].
[1]: https://github.com/systemd/systemd/issues/7998
[2]: https://github.com/ledbettj/systemd-journal/pull/78
[3]: https://github.com/rsyslog/rsyslog/issues/2436
Signed-off-by: Michal Srb <michal@redhat.com>
---
src/plugins/abrt-journal.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/plugins/abrt-journal.c b/src/plugins/abrt-journal.c
index adc9440e..48ae8c99 100644
--- a/src/plugins/abrt-journal.c
+++ b/src/plugins/abrt-journal.c
@@ -35,12 +35,15 @@
struct abrt_journal
{
sd_journal *j;
+ int fd;
};
static int abrt_journal_new_flags(abrt_journal_t **journal, int flags)
{
sd_journal *j;
const int r = sd_journal_open(&j, flags);
+ const int fd = sd_journal_get_fd(j);
+
if (r < 0)
{
log_notice("Failed to open journal: %s", strerror(-r));
@@ -49,6 +52,7 @@ static int abrt_journal_new_flags(abrt_journal_t **journal, int flags)
*journal = g_malloc0(sizeof(**journal));
(*journal)->j = j;
+ (*journal)->fd = fd;
return 0;
}
@@ -452,7 +456,7 @@ int abrt_journal_watch_run_sync(abrt_journal_watch_t *watch)
sigdelset(&mask, SIGKILL);
struct pollfd pollfd;
- pollfd.fd = sd_journal_get_fd(watch->j->j);
+ pollfd.fd = watch->j->fd;
pollfd.events = sd_journal_get_events(watch->j->j);
int r = 0;
--
2.37.3