[systemd-devel] odd seek_tail behaviour

Christian Hesse list at eworm.de
Mon Oct 13 14:56:54 PDT 2014


Christian Hesse <list at eworm.de> on Mon, 2014/10/13 20:22:
> Daurnimator <quae at daurnimator.com> on Mon, 2014/10/13 01:27:
> > Hi All,
> > 
> > I was trying to write a program that tailed the journal, but found that
> > sd_journal_seek_tail() didn't work as expected.
> > That is: that it would seek to the last/most recent thing in the journal,
> > and I could tail things from there.
> > 
> > I whipped up a quick demonstration program, that shows that messages I
> > 'next' through, are before the 'cutoff':
> > 
> > [code and output]
> > 
> > Is this behaviour expected? I'm using systemd 216.
> 
> I do see a similar problem in my code [0]. I do call sd_journal_previous()
> after sd_journal_seek_tail(), but I still do see some older message come up.
> 
> sd_journal_next() is the first I call in while loop. Perhaps even this is a
> problem?
> 
> [0] https://github.com/eworm-de/journal-notify/blob/master/journal-notify.c

Looks like I was right. For any reason sd_journal_next() can jump to old
journal entries (even if sd_journal_previous() has been called before). That
happens before sd_journal_wait() is called the first time.

Sadly I do not know how to reproduce. It happens very seldom and I could not
find the culprit so far.
-- 
main(a){char*c=/*    Schoene Gruesse                         */"B?IJj;MEH"
"CX:;",b;for(a/*    Chris           get my mail address:    */=0;b=c[a++];)
putchar(b-1/(/*               gcc -o sig sig.c && ./sig    */b/42*2-3)*42);}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20141013/cb6d6daf/attachment.sig>


More information about the systemd-devel mailing list