Bug 64614

Summary: make sd_journal_next after sd_journal_seek_tail return 0 and enhance documentation
Product: systemd Reporter: Marius Vollmer <marius.vollmer>
Component: generalAssignee: systemd-bugs
Status: NEW --- QA Contact: systemd-bugs
Severity: normal    
Priority: medium CC: david, mail, pocek, zbyszek
Version: unspecified   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:
Attachments: Test program.

Description Marius Vollmer 2013-05-15 07:05:38 UTC
Created attachment 79325 [details]
Test program.

From the documentation, one might understand that sd_journal_seek_tail move to the last entry and that a subsequent sd_journal_next would access that entry.
(Because it is worded very much like the docs for sd_journal_seek_head, which works that way.)

In fact, sd_journal_seek_tail seems to move to just _after_ the last entry, and one needs to use sd_journal_previous to access it.  I think this should be documented more clearly.

What's worse is that if does call sd_journal_next after sd_journal_seek_tail, this is successful and will access random entries.  Instead, I would expect sd_journal_next to return 0 (or an error).  The attached program demonstrates this.

I might try to provide some patches (docs and code), but with low priority.
Comment 1 Marius Vollmer 2013-06-10 06:43:54 UTC
Not that even with improved documentation, it would still be very good to have sd_journal_next after sd_journal_seek_tail return an error instead of succeeding and moving to a random entry.
Comment 2 Zbigniew Jedrzejewski-Szmek 2013-06-10 14:36:38 UTC
(In reply to comment #1)
> Not that even with improved documentation, it would still be very good to
> have sd_journal_next after sd_journal_seek_tail return an error instead of
> succeeding and moving to a random entry.

You're right, I somehow missed the part about random results...

It would be great if you turned you test program directly into a test that we can include in systemd. I did something like that with your other program (http://cgit.freedesktop.org/systemd/systemd/commit/?id=7a050b54).

I'm pretty sure that sd_journal_next after sd_journal_seek_tail should return 0.
Comment 3 Daurnimator 2014-10-16 15:16:18 UTC
I ran into this bug. Mailing list thread: http://lists.freedesktop.org/archives/systemd-devel/2014-October/023916.html

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.