From 06cc69d44c8ff2b652527357f28acd4cbe77c814 Mon Sep 17 00:00:00 2001 From: Jan Janssen Date: Sat, 6 Sep 2014 10:36:34 +0200 Subject: sd-journal: fix sd_journal_enumerate_unique skipping values sd_journal_enumerate_unique will lock its mmap window to prevent it from being released by calling mmap_cache_get with keep_always=true. This call may return windows that are wider, but compatible with the parameters provided to it. This can result in a mismatch where the window to be released cannot properly be selected, because we have more than one window matching the parameters of mmap_cache_release. Therefore, introduce a release_cookie to be used when releasing the window. https://bugs.freedesktop.org/show_bug.cgi?id=79380 --- src/journal/sd-journal.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/journal/sd-journal.c') diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c index b72a0867e7..479444c8df 100644 --- a/src/journal/sd-journal.c +++ b/src/journal/sd-journal.c @@ -2528,6 +2528,7 @@ _public_ int sd_journal_enumerate_unique(sd_journal *j, const void **data, size_ size_t ol; bool found; int r; + void *release_cookie; /* Proceed to next data object in the field's linked list */ if (j->unique_offset == 0) { @@ -2568,7 +2569,7 @@ _public_ int sd_journal_enumerate_unique(sd_journal *j, const void **data, size_ return -EBADMSG; } - r = journal_file_object_keep(j->unique_file, o, j->unique_offset); + r = journal_file_object_keep(j->unique_file, o, j->unique_offset, &release_cookie); if (r < 0) return r; @@ -2616,13 +2617,13 @@ _public_ int sd_journal_enumerate_unique(sd_journal *j, const void **data, size_ found = true; } - if (found) - continue; - - r = journal_file_object_release(j->unique_file, o, j->unique_offset); + r = journal_file_object_release(j->unique_file, release_cookie); if (r < 0) return r; + if (found) + continue; + r = return_data(j, j->unique_file, o, data, l); if (r < 0) return r; -- cgit v1.2.3-54-g00ecf