chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
logind: fix operation precedence mix-up
[elogind.git]
/
src
/
journal
/
journald.c
diff --git
a/src/journal/journald.c
b/src/journal/journald.c
index e66bb07f84156c9b572a635cc962150e381e5c6f..36f9abe47ecd957e347a45f7be11e0a09840e2fa 100644
(file)
--- a/
src/journal/journald.c
+++ b/
src/journal/journald.c
@@
-313,7
+313,7
@@
static JournalFile* find_journal(Server *s, uid_t uid) {
journal_file_close(f);
}
journal_file_close(f);
}
- r = journal_file_open_reliably(p, O_RDWR|O_CREAT, 0640, s->system_journal, &f);
+ r = journal_file_open_reliably(p, O_RDWR|O_CREAT, 0640,
&s->system_metrics,
s->system_journal, &f);
free(p);
if (r < 0)
free(p);
if (r < 0)
@@
-478,6
+478,10
@@
static void write_to_journal(Server *s, uid_t uid, struct iovec *iovec, unsigned
server_rotate(s);
server_vacuum(s);
vacuumed = true;
server_rotate(s);
server_vacuum(s);
vacuumed = true;
+
+ f = find_journal(s, uid);
+ if (!f)
+ return;
}
for (;;) {
}
for (;;) {
@@
-493,7
+497,9
@@
static void write_to_journal(Server *s, uid_t uid, struct iovec *iovec, unsigned
r != -EBADMSG && /* corrupted */
r != -ENODATA && /* truncated */
r != -EHOSTDOWN && /* other machine */
r != -EBADMSG && /* corrupted */
r != -ENODATA && /* truncated */
r != -EHOSTDOWN && /* other machine */
- r != -EPROTONOSUPPORT /* unsupported feature */)) {
+ r != -EPROTONOSUPPORT && /* unsupported feature */
+ r != -EBUSY && /* unclean shutdown */
+ r != -ESHUTDOWN /* already archived */)) {
log_error("Failed to write entry, ignoring: %s", strerror(-r));
return;
}
log_error("Failed to write entry, ignoring: %s", strerror(-r));
return;
}
@@
-502,6
+508,8
@@
static void write_to_journal(Server *s, uid_t uid, struct iovec *iovec, unsigned
log_info("Allocation limit reached, rotating.");
else if (r == -EHOSTDOWN)
log_info("Journal file from other machine, rotating.");
log_info("Allocation limit reached, rotating.");
else if (r == -EHOSTDOWN)
log_info("Journal file from other machine, rotating.");
+ else if (r == -EBUSY)
+ log_info("Unlcean shutdown, rotating.");
else
log_warning("Journal file corrupted, rotating.");
else
log_warning("Journal file corrupted, rotating.");
@@
-509,6
+517,10
@@
static void write_to_journal(Server *s, uid_t uid, struct iovec *iovec, unsigned
server_vacuum(s);
vacuumed = true;
server_vacuum(s);
vacuumed = true;
+ f = find_journal(s, uid);
+ if (!f)
+ return;
+
log_info("Retrying write.");
}
}
log_info("Retrying write.");
}
}
@@
-856,7
+868,8
@@
static void forward_syslog_iovec(Server *s, const struct iovec *iovec, unsigned
return;
}
return;
}
- log_debug("Failed to forward syslog message: %m");
+ if (errno != ENOENT)
+ log_debug("Failed to forward syslog message: %m");
}
static void forward_syslog_raw(Server *s, int priority, const char *buffer, struct ucred *ucred, struct timeval *tv) {
}
static void forward_syslog_raw(Server *s, int priority, const char *buffer, struct ucred *ucred, struct timeval *tv) {
@@
-2001,13
+2014,10
@@
static int system_journal_open(Server *s) {
if (!fn)
return -ENOMEM;
if (!fn)
return -ENOMEM;
- r = journal_file_open_reliably(fn, O_RDWR|O_CREAT, 0640, NULL, &s->system_journal);
+ r = journal_file_open_reliably(fn, O_RDWR|O_CREAT, 0640,
&s->system_metrics,
NULL, &s->system_journal);
free(fn);
if (r >= 0) {
free(fn);
if (r >= 0) {
- journal_default_metrics(&s->system_metrics, s->system_journal->fd);
-
- s->system_journal->metrics = s->system_metrics;
s->system_journal->compress = s->compress;
server_fix_perms(s, s->system_journal, 0);
s->system_journal->compress = s->compress;
server_fix_perms(s, s->system_journal, 0);
@@
-2033,7
+2043,7
@@
static int system_journal_open(Server *s) {
* if it already exists, so that we can flush
* it into the system journal */
* if it already exists, so that we can flush
* it into the system journal */
- r = journal_file_open(fn, O_RDWR, 0640, NULL, &s->runtime_journal);
+ r = journal_file_open(fn, O_RDWR, 0640,
&s->runtime_metrics,
NULL, &s->runtime_journal);
free(fn);
if (r < 0) {
free(fn);
if (r < 0) {
@@
-2049,7
+2059,7
@@
static int system_journal_open(Server *s) {
* it if necessary. */
(void) mkdir_parents(fn, 0755);
* it if necessary. */
(void) mkdir_parents(fn, 0755);
- r = journal_file_open_reliably(fn, O_RDWR|O_CREAT, 0640, NULL, &s->runtime_journal);
+ r = journal_file_open_reliably(fn, O_RDWR|O_CREAT, 0640,
&s->runtime_metrics,
NULL, &s->runtime_journal);
free(fn);
if (r < 0) {
free(fn);
if (r < 0) {
@@
-2059,9
+2069,6
@@
static int system_journal_open(Server *s) {
}
if (s->runtime_journal) {
}
if (s->runtime_journal) {
- journal_default_metrics(&s->runtime_metrics, s->runtime_journal->fd);
-
- s->runtime_journal->metrics = s->runtime_metrics;
s->runtime_journal->compress = s->compress;
server_fix_perms(s, s->runtime_journal, 0);
s->runtime_journal->compress = s->compress;
server_fix_perms(s, s->runtime_journal, 0);
@@
-2140,11
+2147,8
@@
finish:
journal_file_close(s->runtime_journal);
s->runtime_journal = NULL;
journal_file_close(s->runtime_journal);
s->runtime_journal = NULL;
- if (r >= 0) {
- char path[] = "/run/log/journal/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
- sd_id128_to_string(machine, path + 17);
- rm_rf(path, false, true, false);
- }
+ if (r >= 0)
+ rm_rf("/run/log/journal", false, true, false);
return r;
}
return r;
}
@@
-2221,6
+2225,8
@@
static int process_event(Server *s, struct epoll_event *ev) {
return -errno;
}
return -errno;
}
+ log_info("Received SIG%s", signal_to_string(sfsi.ssi_signo));
+
if (sfsi.ssi_signo == SIGUSR1) {
touch("/run/systemd/journal/flushed");
server_flush_to_var(s);
if (sfsi.ssi_signo == SIGUSR1) {
touch("/run/systemd/journal/flushed");
server_flush_to_var(s);
@@
-2233,7
+2239,6
@@
static int process_event(Server *s, struct epoll_event *ev) {
return 1;
}
return 1;
}
- log_debug("Received SIG%s", signal_to_string(sfsi.ssi_signo));
return 0;
} else if (ev->data.fd == s->proc_kmsg_fd) {
return 0;
} else if (ev->data.fd == s->proc_kmsg_fd) {