sd-journal: fix sd_journal_seek_monotonic_usec()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 7 Aug 2024 03:01:45 +0000 (12:01 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 14 Aug 2024 19:43:32 +0000 (04:43 +0900)
commit9c04f67884140cddea95a876e69914a49e32e8c6
treee3d728353632139f45ca4df4077f6dd5d78fb28e
parenta2e4b8d866e57fbcb345510761825a172362f05f
sd-journal: fix sd_journal_seek_monotonic_usec()

This fixes the following issues:

- We have a journal file, which contains entries of boot A and B. Let T
  be the timestamp of the _last_ entry of boot A.
  If sd_journal_seek_monotonic_usec() is called for boot A with a timestamp
  _after_ T, following sd_journal_next() will provide the _first_ entry of
  boot A, rather than the first entry of boot B.

- We have two journal files X and Y. The file X contains entries of boot A.
  Let T be the timestamp of the _last_ entry of boot A in file X. The file Y
  contains entries of boot A after timestamp T.
  If sd_journal_seek_monotonic_usec() is called for boot A with a
  timestamp _after_ T, following sd_journal_next() will provide the
  _first_ entry of boot A, whose timestamp is of course earlier than T.
src/libsystemd/sd-journal/sd-journal.c