]> git.ipfire.org Git - thirdparty/systemd.git/commit
sd-journal: rework generic_array_bisect() 29402/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 27 Sep 2023 17:14:31 +0000 (02:14 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 4 Nov 2023 02:01:30 +0000 (11:01 +0900)
commitab8f553d1e09088fb1f633e014299e7bf6c30c9e
treef060ed3d9ebcd307013b0288d47b7f31a08c1ad0
parentf6548f053d29542d5f640d0d5bf2dca68e808c24
sd-journal: rework generic_array_bisect()

- Rename generic_array_bisect_one() -> generic_array_bisect_step(), as there
  is also generic_array_bisect_plus_one(), so the original name is confusing.
- Make generic_array_bisect_step() return TEST_GOTO_NEXT or TEST_GOTO_PREVIOUS
  when the current array does not contain any matching entries.
- Make generic_array_bisect_step() symmetric with respect to the direction
  we are going to, except for the journal corruption handling.
- Make generic_array_bisect_step() gracefully handle journal corruptions,
  so the corruption handling in the caller side can be mostly dropped.
- Especially, when the last entry in an array is corrupted, previously
  we tried to find a valid entry sequentially from the end of the array,
  but now we anyway bisect the array. That should improve performance of
  reading corrupted journal files.
- Return earlier when no entry linked to the chained array (n == 0).
- Add many comments.

No behavior change unless journal is corrupted.
src/libsystemd/sd-journal/journal-file.c
test/units/testsuite-04.journal.sh