dlt-system: move journal reading to its own thread #471
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Reading from journal uses an endless loop which only exits when no new messages are read from the journal.
This is a problem when the local buffer of the application gets filled i.e. due dlt-daemon being busy and not accepting current messages.
In this case the thread waits for 500ms and tries again to read messages from the journal.
When new messages are available they also will be written to dlt. If this cycle continues for a while it is possible that other tasks, which use the same thread and are controlled via a timer, are not executed anymore as the funtion
get_journal_msg
will not exit. This will lead to termination through the systemd watchdog, as sd_notify is not called anymore.To circumvent this issue, reading logs from journald is moved into a separate thread.
Furthermore this commit fixes some invalid free when no configuration is passed to dlt-system as well as adding missing initialization which also can lead to crashes.
Although these issues are not responsible for the crash on the system, as they will only happen on application shutdown.
The program was tested solely for our own use cases, which might differ from yours.
Licensed under Mozilla Public License Version 2.0
Alexander Mohr, [email protected], Mercedes-Benz Tech Innovation GmbH, imprint