[systemd-devel] Something wrong with sd_journal_add_match

Dennis Semakin insane79 at yandex.ru
Thu Jun 23 12:14:41 UTC 2016


sd_journal_get_data() returns 0 (zero) in that case.


22.06.2016, 14:51, "Luca BRUNO" <lucab at debian.org>:
> 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
>
> --
> «Доверяй, но проверяй»
> ,
>
> _______________________________________________
> systemd-devel mailing list
> systemd-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/systemd-devel


More information about the systemd-devel mailing list