summaryrefslogtreecommitdiff
path: root/src/journal/sd-journal.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2012-07-10 21:46:11 +0200
committerLennart Poettering <lennart@poettering.net>2012-07-10 21:46:11 +0200
commite02d1cf72d115d1d61defdca5b551672d876c6bd (patch)
treec4a5a396b17c67b74eba1d7ca7f9d62eb4928b49 /src/journal/sd-journal.c
parent166503dada92d7ca3570a653e07a51ed826b7c8a (diff)
journal: introduce sd_journal_wait() to simplify writing synchronous clients
Diffstat (limited to 'src/journal/sd-journal.c')
-rw-r--r--src/journal/sd-journal.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c
index 75884594a1..149dc10bdf 100644
--- a/src/journal/sd-journal.c
+++ b/src/journal/sd-journal.c
@@ -24,6 +24,7 @@
#include <stddef.h>
#include <unistd.h>
#include <sys/inotify.h>
+#include <sys/poll.h>
#include "sd-journal.h"
#include "journal-def.h"
@@ -1622,6 +1623,20 @@ _public_ int sd_journal_process(sd_journal *j) {
}
}
+_public_ int sd_journal_wait(sd_journal *j, uint64_t timeout_usec) {
+ int r, k;
+
+ assert(j);
+
+ r = fd_wait_for_event(j->inotify_fd, POLLIN, timeout_usec);
+ k = sd_journal_process(j);
+
+ if (r < 0)
+ return r;
+
+ return k;
+}
+
_public_ int sd_journal_get_cutoff_realtime_usec(sd_journal *j, uint64_t *from, uint64_t *to) {
Iterator i;
JournalFile *f;