diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2012-11-01 22:36:52 +0100 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2014-03-17 01:55:47 -0400 |
commit | 63c8666b824e8762ffb73647e1caee165dfbc868 (patch) | |
tree | 10fad3b88839f275eda3e57957582853e51fd900 /src/journal | |
parent | fc55baee9964a118afbddbf82b8e667a0ad80b99 (diff) |
journal: extract duplicated code to a function
Diffstat (limited to 'src/journal')
-rw-r--r-- | src/journal/journald-server.c | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c index 0ab8c7095b..ef39d0a602 100644 --- a/src/journal/journald-server.c +++ b/src/journal/journald-server.c @@ -364,6 +364,20 @@ void server_sync(Server *s) { s->sync_scheduled = false; } +static void do_vacuum(Server *s, char *ids, JournalFile *f, const char* path, + JournalMetrics *metrics) { + char *p; + int r; + + if (!f) + return; + + p = strappenda(path, ids); + r = journal_directory_vacuum(p, metrics->max_use, s->max_retention_usec, &s->oldest_file_usec); + if (r < 0 && r != -ENOENT) + log_error("Failed to vacuum %s: %s", p, strerror(-r)); +} + void server_vacuum(Server *s) { char ids[33]; sd_id128_t machine; @@ -378,24 +392,10 @@ void server_vacuum(Server *s) { log_error("Failed to get machine ID: %s", strerror(-r)); return; } - sd_id128_to_string(machine, ids); - if (s->system_journal) { - char *p = strappenda("/var/log/journal/", ids); - - r = journal_directory_vacuum(p, s->system_metrics.max_use, s->max_retention_usec, &s->oldest_file_usec); - if (r < 0 && r != -ENOENT) - log_error("Failed to vacuum %s: %s", p, strerror(-r)); - } - - if (s->runtime_journal) { - char *p = strappenda("/run/log/journal/", ids); - - r = journal_directory_vacuum(p, s->runtime_metrics.max_use, s->max_retention_usec, &s->oldest_file_usec); - if (r < 0 && r != -ENOENT) - log_error("Failed to vacuum %s: %s", p, strerror(-r)); - } + do_vacuum(s, ids, s->system_journal, "/var/log/journal/", &s->system_metrics); + do_vacuum(s, ids, s->runtime_journal, "/run/log/journal/", &s->runtime_metrics); s->cached_available_space_timestamp = 0; } |