chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
journal: use sd_journal_close on error in sd_journal_new
[elogind.git]
/
src
/
journal
/
sd-journal.c
diff --git
a/src/journal/sd-journal.c
b/src/journal/sd-journal.c
index 89045600942d8f6af9b9d943e0d54f7a0eb7599d..2c5ee3f8f683a4d35ffb273ad8500b49e79a04a1 100644
(file)
--- a/
src/journal/sd-journal.c
+++ b/
src/journal/sd-journal.c
@@
-1321,10
+1321,12
@@
static int add_directory(sd_journal *j, const char *prefix, const char *dirname)
assert(prefix);
assert(dirname);
assert(prefix);
assert(dirname);
+ log_debug("Considering %s/%s.", prefix, dirname);
+
if ((j->flags & SD_JOURNAL_LOCAL_ONLY) &&
(sd_id128_from_string(dirname, &id) < 0 ||
sd_id128_get_machine(&mid) < 0 ||
if ((j->flags & SD_JOURNAL_LOCAL_ONLY) &&
(sd_id128_from_string(dirname, &id) < 0 ||
sd_id128_get_machine(&mid) < 0 ||
- !
sd_id128_equal(id, mid
)))
+ !
(sd_id128_equal(id, mid) || path_startswith(prefix, "/run")
)))
return 0;
path = strjoin(prefix, "/", dirname, NULL);
return 0;
path = strjoin(prefix, "/", dirname, NULL);
@@
-1566,37
+1568,21
@@
static sd_journal *journal_new(int flags, const char *path) {
if (path) {
j->path = strdup(path);
if (path) {
j->path = strdup(path);
- if (!j->path) {
- free(j);
- return NULL;
- }
+ if (!j->path)
+ goto fail;
}
j->files = hashmap_new(string_hash_func, string_compare_func);
}
j->files = hashmap_new(string_hash_func, string_compare_func);
- if (!j->files) {
- free(j->path);
- free(j);
- return NULL;
- }
-
j->directories_by_path = hashmap_new(string_hash_func, string_compare_func);
j->directories_by_path = hashmap_new(string_hash_func, string_compare_func);
- if (!j->directories_by_path) {
- hashmap_free(j->files);
- free(j->path);
- free(j);
- return NULL;
- }
-
j->mmap = mmap_cache_new();
j->mmap = mmap_cache_new();
- if (!j->mmap) {
- hashmap_free(j->files);
- hashmap_free(j->directories_by_path);
- free(j->path);
- free(j);
- return NULL;
- }
+ if (!j->files || !j->directories_by_path || !j->mmap)
+ goto fail;
return j;
return j;
+
+fail:
+ sd_journal_close(j);
+ return NULL;
}
_public_ int sd_journal_open(sd_journal **ret, int flags) {
}
_public_ int sd_journal_open(sd_journal **ret, int flags) {
@@
-1866,7
+1852,7
@@
_public_ int sd_journal_get_data(sd_journal *j, const char *field, const void **
*data = o->data.payload;
*size = t;
*data = o->data.payload;
*size = t;
- return
1
;
+ return
0
;
}
r = journal_file_move_to_object(f, OBJECT_ENTRY, f->current_offset, &o);
}
r = journal_file_move_to_object(f, OBJECT_ENTRY, f->current_offset, &o);