Correct way to read from journal after poll() returns

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,
I am updating a system from systemd v250 to systemd v255. There is some small utility on the system using sd_journal_add_match() to react on coredumps being printed to the journal:

sd_journal_open(...);
poll_fd = sd_journal_get_fd(...);
sd_journal_seek_tail(...);
sd_journal_previous(...);
sd_journal_add_match(..., "MESSAGE_ID=fc2e22bc6ee647b6b90729ab34a250b1");
poll(poll_fd)

When poll returns, sd_journal_process() is called, followed by sd_journal_next() in case sd_journal_process() does not return SD_JOURNAL_NOP

This is very similar to https://github.com/systemd/systemd/blob/main/man/journal-iterate-poll.c , except that there is a call to sd_journal_add_match, and that sd_journal_next is called after poll().

This used to work with systemd v250, however it does not work with v255 (sd_journal_next() always returns 0 which means "no new data"). I bisected it, and the commit after which it stops working is https://github.com/systemd/systemd/commit/7a4ee861615101ddd2f95056cf30e69e41da86ce 

What is the correct way to read the journal entry after poll() returns, meaning a match as configured by sd_journal_add_match() was found? Should sd_journal_get_data() be called directly instead of sd_journal_next()?

I'd like to extend  https://github.com/systemd/systemd/blob/main/man/journal-iterate-poll.c  to make the proper way to do this clearer, in case sd_journal_next() is not the correct way.

Thanks,
Étienne

[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux