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

-- 
«Доверяй, но проверяй»

Attachment: signature.asc
Description: This is a digitally signed message part.

_______________________________________________
systemd-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/systemd-devel

Reply via email to