sdjournal: JournalReader.Follow is not thread-safe
corhere opened this issue · 0 comments
corhere commented
The "Thread safety" section of the sd-journal
manpage says:
Functions that operate on sd_journal objects are thread agnostic — given sd_journal pointer may only be used from one specific thread at all times (and it has to be the very same one during the entire lifetime of the object), but multiple, independent threads may use multiple, independent objects safely.
That section was added to the documentation in systemd v232 (wayback machine).
Code using sdjournal.Journal
can abide by this constraint by e.g.:
runtime.LockOSThread()
j, err := sdjournal.NewJournal()
// Use j exclusively from this goroutine
On the other hand, func (*JournalReader) Follow
cannot be used thread-safely as it calls Journal
methods from spawned goroutines.
Lines 232 to 236 in 9ed442a