Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sdjournal: JournalReader.Follow is not thread-safe #394

Open
corhere opened this issue Jan 28, 2022 · 0 comments
Open

sdjournal: JournalReader.Follow is not thread-safe #394

corhere opened this issue Jan 28, 2022 · 0 comments

Comments

@corhere
Copy link

corhere commented Jan 28, 2022

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.

go func() {
status := r.journal.Wait(100 * time.Millisecond)
waitCh <- status
waitGroup.Done()
}()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant