sd-journal: check sd-event state before setting up post change timer
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 28 Dec 2023 19:31:21 +0000 (04:31 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 28 Dec 2023 21:39:06 +0000 (06:39 +0900)
commit5b201ffb1e72100dc7a112c95bbac0ccbc98ab0d
treef5ee45c7d9ef62c07a7de325e0080e5d5102087a
parent0802e9d8de1f9543ff8a1c96405afe8c747ff427
sd-journal: check sd-event state before setting up post change timer

The similar check already exists in schedule_post_change().

The function is currently called at two places.
- journal_file_open() in sd-journal:
  In this case, if the timer is not set up, then journal_file_post_change()
  will be called at the end of journal_file_append_entry(). So, the necessary
  task will be done sequentially when an journal entry is stored to the opened
  journal file. That is desired when the function is called at outside of the
  event loop.
- server_open_journal() in journald:
  This is not called after we exit the event loop.

So, we can safely do nothing in the function if the event loop is being
finished or already finished.

Fixes #30644.
src/libsystemd/sd-journal/journal-file.c