[systemd-devel] Something wrong with sd_journal_add_match
Luca BRUNO
lucab at debian.org
Wed Jun 22 11:41:56 UTC 2016
On Wednesday 22 June 2016 12:10:14 Dennis Semakin wrote:
> The task is to obtain messages _only_ with specified fields (e.g.
> MESSAGE_ID=bla-bla-bla).
> And problem is that I can see incoming messages even when sending tool is
> not running (no execution). Looks like I got all messages from journal
> (kernel, other services, etc.).
> for (;;) {
>
> const void *data;
> size_t length;
>
> ret = sd_journal_next(sdj);
> if (ret == 0) {
> ret = sd_journal_wait(sdj, (uint64_t) -1);
> printf("wait ret = %d \n", ret);
> }
>
> sd_journal_get_data(sdj, "MESSAGE", &data, &length);
> printf(">%.*s<\n", (int) length, data);
I think I've seen something similar, so I'll note it here even if I'm not sure
if my understanding is correct:
sd_journal_wait() will trigger on *any* events, while sd_journal_get_data()
will apply the filter and find no matching entries.
I'm not sure why you see a consistent printing behavior, though. Can you check
the return value of sd_journal_get_data() in that case?
NB: I'm not much familiar with that codebase and haven't digged into the
source enough to confirm my speculation, so take it cum grano salis.
Cheers, Luca
--
«Доверяй, но проверяй»
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part.
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20160622/99f9659a/attachment.sig>
More information about the systemd-devel
mailing list