Revert "Revert "journal: Make sd_journal_previous/next() return 0 at HEAD/TAIL""
authorChen Qi <Qi.Chen@windriver.com>
Fri, 24 Feb 2023 04:36:55 +0000 (12:36 +0800)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 21 May 2023 17:54:40 +0000 (02:54 +0900)
commit7a4ee861615101ddd2f95056cf30e69e41da86ce
tree7f22aa4cd174ee0c86eb98ae9653bfbbe8f5ae37
parenta94149601a4398b8d5578ef4e77f833992834817
Revert "Revert "journal: Make sd_journal_previous/next() return 0 at HEAD/TAIL""

This reverts commit 1db6dbb1dcdacfd7d2b4c84562fc6e77bc8c43a5.

The original patch was reverted because of issue #25369. The issue was created
because it wrongly assumed that sd_journal_seek_tail() seeks to 'current' tail.
But in fact, only when a subsequent sd_journal_previous() is called that it's
pointing to the tail at that time. The concept of 'tail' in sd_journal_seek_tail()
only has a logical meaning, and a sd_journal_previous is needed. In fact, if we
look at the codes in journalctl, we can see sd_journal_seek_tail() is followed by
sd_journal_previous(). By contrary, a sd_journal_next() after a 'logical' tail does
not make much sense. So the original patch is correct, and projects that are
using 'sd_journal_next()' right after 'sd_journal_seek_tail()' should do fixes
as in https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/2823#note_1637715.
src/journal/test-journal-interleaving.c
src/libsystemd/sd-journal/sd-journal.c