summaryrefslogtreecommitdiff
path: root/src/journal/sd-journal.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2012-08-14 22:02:24 +0200
committerLennart Poettering <lennart@poettering.net>2012-08-16 17:10:56 +0200
commit16e9f408fa9a9626059bdd6c89dc175e06b9e976 (patch)
tree89a6730a2f044626c9ca67d278dd6ac6a844aec3 /src/journal/sd-journal.c
parent405053fafa88022c68e7adf04c91a56c1cde7dd8 (diff)
journal: implement generic sharable mmap caching logic
instead of having one simple per-file cache implement an more comprehensive one that works for multiple files and can actually maintain multiple maps per file and per object type.
Diffstat (limited to 'src/journal/sd-journal.c')
-rw-r--r--src/journal/sd-journal.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c
index 359a7cac3e..41526b35bf 100644
--- a/src/journal/sd-journal.c
+++ b/src/journal/sd-journal.c
@@ -1118,7 +1118,7 @@ static int add_file(sd_journal *j, const char *prefix, const char *filename) {
return 0;
}
- r = journal_file_open(path, O_RDONLY, 0, false, false, NULL, NULL, &f);
+ r = journal_file_open(path, O_RDONLY, 0, false, false, NULL, j->mmap, NULL, &f);
free(path);
if (r < 0) {
@@ -1439,6 +1439,17 @@ static sd_journal *journal_new(int flags, const char *path) {
return NULL;
}
+ /* One context for each type, plus the zeroth catchall
+ * context. One fd for each file plus one for each type, which
+ * is need when verifying things */
+ j->mmap = mmap_cache_new(_OBJECT_TYPE_MAX, JOURNAL_FILES_MAX + _OBJECT_TYPE_MAX);
+ if (!j->mmap) {
+ hashmap_free(j->files);
+ hashmap_free(j->directories_by_path);
+ free(j->path);
+ free(j);
+ }
+
return j;
}
@@ -1527,6 +1538,9 @@ _public_ void sd_journal_close(sd_journal *j) {
sd_journal_flush_matches(j);
+ if (j->mmap)
+ mmap_cache_unref(j->mmap);
+
free(j->path);
free(j);
}