#define FAILED_TO_WRITE_ENTRY_RATELIMIT ((const RateLimit) { .interval = 1 * USEC_PER_SEC, .burst = 1 })
-static int determine_path_usage(
+static int server_determine_path_usage(
Server *s,
const char *path,
uint64_t *ret_used,
if (space->timestamp != 0 && usec_add(space->timestamp, RECHECK_SPACE_USEC) > ts)
return 0;
- r = determine_path_usage(s, storage->path, &vfs_used, &vfs_avail);
+ r = server_determine_path_usage(s, storage->path, &vfs_used, &vfs_avail);
if (r < 0)
return r;
return s->system_journal ? &s->system_storage : &s->runtime_storage;
}
-static int determine_space(Server *s, uint64_t *available, uint64_t *limit) {
+static int server_determine_space(Server *s, uint64_t *available, uint64_t *limit) {
JournalStorage *js;
int r;
#endif
}
-static int open_journal(
+static int server_open_journal(
Server *s,
bool reliably,
const char *fname,
return r;
}
-static bool flushed_flag_is_set(Server *s) {
+static bool server_flushed_flag_is_set(Server *s) {
const char *fn;
assert(s);
return access(fn, F_OK) >= 0;
}
-static int system_journal_open(Server *s, bool flush_requested, bool relinquish_requested) {
+static int server_system_journal_open(
+ Server *s,
+ bool flush_requested,
+ bool relinquish_requested) {
+
const char *fn;
int r = 0;
if (!s->system_journal &&
IN_SET(s->storage, STORAGE_PERSISTENT, STORAGE_AUTO) &&
- (flush_requested || flushed_flag_is_set(s)) &&
+ (flush_requested || server_flushed_flag_is_set(s)) &&
!relinquish_requested) {
/* If in auto mode: first try to create the machine path, but not the prefix.
(void) mkdir(s->system_storage.path, 0755);
fn = strjoina(s->system_storage.path, "/system.journal");
- r = open_journal(
+ r = server_open_journal(
s,
/* reliably= */ true,
fn,
/* Try to open the runtime journal, but only if it already exists, so that we can
* flush it into the system journal */
- r = open_journal(
+ r = server_open_journal(
s,
/* reliably= */ false,
fn,
(void) mkdir_parents(s->runtime_storage.path, 0755);
(void) mkdir(s->runtime_storage.path, 0750);
- r = open_journal(
+ r = server_open_journal(
s,
/* reliably= */ true,
fn,
return r;
}
-static int find_user_journal(Server *s, uid_t uid, ManagedJournalFile **ret) {
+static int server_find_user_journal(Server *s, uid_t uid, ManagedJournalFile **ret) {
_cleanup_(managed_journal_file_closep) ManagedJournalFile *f = NULL;
_cleanup_free_ char *p = NULL;
int r;
(void) managed_journal_file_close(first);
}
- r = open_journal(
+ r = server_open_journal(
s,
/* reliably= */ true,
p,
return 0;
}
-static ManagedJournalFile* find_journal(Server *s, uid_t uid) {
+static ManagedJournalFile* server_find_journal(Server *s, uid_t uid) {
int r;
assert(s);
* recover from failed rotates (or anything else that's left the journals as NULL).
*
* Fixes https://github.com/systemd/systemd/issues/3968 */
- (void) system_journal_open(s, false, false);
+ (void) server_system_journal_open(s, /* flush_requested= */ false, /* relinquish_requested= */ false);
/* We split up user logs only on /var, not on /run. If the runtime file is open, we write to it
* exclusively, in order to guarantee proper order as soon as we flush /run to /var and close the
if (!uid_for_system_journal(uid)) {
ManagedJournalFile *f = NULL;
- r = find_user_journal(s, uid, &f);
+ r = server_find_user_journal(s, uid, &f);
if (r >= 0)
return ASSERT_PTR(f);
return s->system_journal;
}
-static int do_rotate(
+static int server_do_rotate(
Server *s,
ManagedJournalFile **f,
const char* name,
log_debug("Rotating...");
/* First, rotate the system journal (either in its runtime flavour or in its runtime flavour) */
- (void) do_rotate(s, &s->runtime_journal, "runtime", false, 0);
- (void) do_rotate(s, &s->system_journal, "system", s->seal, 0);
+ (void) server_do_rotate(s, &s->runtime_journal, "runtime", /* seal= */ false, /* uid= */ 0);
+ (void) server_do_rotate(s, &s->system_journal, "system", s->seal, /* uid= */ 0);
/* Then, rotate all user journals we have open (keeping them open) */
ORDERED_HASHMAP_FOREACH_KEY(f, k, s->user_journals) {
- r = do_rotate(s, &f, "user", s->seal, PTR_TO_UID(k));
+ r = server_do_rotate(s, &f, "user", s->seal, PTR_TO_UID(k));
if (r >= 0)
ordered_hashmap_replace(s->user_journals, k, f);
else if (!f)
s->sync_scheduled = false;
}
-static void do_vacuum(Server *s, JournalStorage *storage, bool verbose) {
+static void server_do_vacuum(Server *s, JournalStorage *storage, bool verbose) {
int r;
s->oldest_file_usec = 0;
if (s->system_journal)
- do_vacuum(s, &s->system_storage, verbose);
+ server_do_vacuum(s, &s->system_storage, verbose);
if (s->runtime_journal)
- do_vacuum(s, &s->runtime_storage, verbose);
+ server_do_vacuum(s, &s->runtime_storage, verbose);
}
static void server_cache_machine_id(Server *s) {
}
}
-static void write_to_journal(Server *s, uid_t uid, struct iovec *iovec, size_t n, int priority) {
+static void server_write_to_journal(Server *s, uid_t uid, struct iovec *iovec, size_t n, int priority) {
bool vacuumed = false, rotate = false;
struct dual_timestamp ts;
ManagedJournalFile *f;
rotate = true;
} else {
- f = find_journal(s, uid);
+ f = server_find_journal(s, uid);
if (!f)
return;
server_vacuum(s, false);
vacuumed = true;
- f = find_journal(s, uid);
+ f = server_find_journal(s, uid);
if (!f)
return;
}
server_rotate(s);
server_vacuum(s, false);
- f = find_journal(s, uid);
+ f = server_find_journal(s, uid);
if (!f)
return;
iovec[n++] = IOVEC_MAKE_STRING(k); \
} \
-static void dispatch_message_real(
+static void server_dispatch_message_real(
Server *s,
struct iovec *iovec, size_t n, size_t m,
const ClientContext *c,
else
journal_uid = 0;
- write_to_journal(s, journal_uid, iovec, n, priority);
+ server_write_to_journal(s, journal_uid, iovec, n, priority);
}
void server_driver_message(Server *s, pid_t object_pid, const char *message_id, const char *format, ...) {
va_end(ap);
if (r >= 0)
- dispatch_message_real(s, iovec, n, m, s->my_context, NULL, LOG_INFO, object_pid);
+ server_dispatch_message_real(s, iovec, n, m, s->my_context, /* tv= */ NULL, LOG_INFO, object_pid);
while (k < n)
free(iovec[k++].iov_base);
n = 3;
iovec[n++] = IOVEC_MAKE_STRING("PRIORITY=4");
iovec[n++] = IOVEC_MAKE_STRING(buf);
- dispatch_message_real(s, iovec, n, m, s->my_context, NULL, LOG_INFO, object_pid);
+ server_dispatch_message_real(s, iovec, n, m, s->my_context, /* tv= */ NULL, LOG_INFO, object_pid);
}
}
return;
if (c && c->unit) {
- (void) determine_space(s, &available, NULL);
+ (void) server_determine_space(s, &available, /* limit= */ NULL);
rl = journal_ratelimit_test(s->ratelimit, c->unit, c->log_ratelimit_interval, c->log_ratelimit_burst, priority & LOG_PRIMASK, available);
if (rl == 0)
NULL);
}
- dispatch_message_real(s, iovec, n, m, c, tv, priority, object_pid);
+ server_dispatch_message_real(s, iovec, n, m, c, tv, priority, object_pid);
}
int server_flush_to_var(Server *s, bool require_flag_file) {
if (!s->runtime_journal) /* Nothing to flush? */
return 0;
- if (require_flag_file && !flushed_flag_is_set(s))
+ if (require_flag_file && !server_flushed_flag_is_set(s))
return 0;
- (void) system_journal_open(s, true, false);
+ (void) server_system_journal_open(s, /* flush_requested=*/ true, /* relinquish_requested= */ false);
if (!s->system_journal)
return 0;
log_debug("Relinquishing %s...", s->system_storage.path);
- (void) system_journal_open(s, false, true);
+ (void) server_system_journal_open(s, /* flush_requested */ false, /* relinquish_requested=*/ true);
s->system_journal = managed_journal_file_close(s->system_journal);
ordered_hashmap_clear_with_destructor(s->user_journals, managed_journal_file_close);
return 0;
}
-static int setup_signals(Server *s) {
+static int server_setup_signals(Server *s) {
int r;
assert(s);
return 1;
}
-static int set_namespace(Server *s, const char *namespace) {
+static int server_set_namespace(Server *s, const char *namespace) {
assert(s);
if (!namespace)
},
};
- r = set_namespace(s, namespace);
+ r = server_set_namespace(s, namespace);
if (r < 0)
return r;
if (r < 0)
return r;
- r = setup_signals(s);
+ r = server_setup_signals(s);
if (r < 0)
return r;
(void) client_context_acquire_default(s);
- r = system_journal_open(s, false, false);
+ r = server_system_journal_open(s, /* flush_requested= */ false, /* relinquish_requested= */ false);
if (r < 0)
return r;