Skip to content

Commit 4801e55

Browse files
committed
journald-server: always touch state file in signal handler
`journalctl --relinquish-var` waits on that file, so we must create if even if nothing has really happened. RHEL-only Related: #2176892
1 parent b2ca5e1 commit 4801e55

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/journal/journald-server.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,8 +1259,6 @@ static int dispatch_sigrtmin1(sd_event_source *es, const struct signalfd_siginfo
12591259
}
12601260

12611261
static void relinquish_var(Server *s) {
1262-
int r;
1263-
12641262
assert(s);
12651263

12661264
if (s->storage == STORAGE_NONE)
@@ -1278,15 +1276,15 @@ static void relinquish_var(Server *s) {
12781276
if (unlink("/run/systemd/journal/flushed") < 0 && errno != ENOENT)
12791277
log_warning_errno(errno, "Failed to unlink /run/systemd/journal/flushed, ignoring: %m") ;
12801278

1281-
r = write_timestamp_file_atomic("/run/systemd/journal/relinquished", now(CLOCK_MONOTONIC));
1282-
if (r < 0)
1283-
log_warning_errno(r, "Failed to write /run/systemd/journal/relinquished, ignoring: %m");
1279+
/* NOTE: We don't create our own state file here, because dispatch_sigrtmin2() has to do it anyway.
1280+
* But if this function is ever called from another place, the creation must be done here too. */
12841281

12851282
return;
12861283
}
12871284

12881285
static int dispatch_sigrtmin2(sd_event_source *es, const struct signalfd_siginfo *si, void *userdata) {
12891286
Server *s = userdata;
1287+
int r;
12901288

12911289
assert(s);
12921290
assert(si);
@@ -1295,6 +1293,10 @@ static int dispatch_sigrtmin2(sd_event_source *es, const struct signalfd_siginfo
12951293

12961294
relinquish_var(s);
12971295

1296+
r = write_timestamp_file_atomic("/run/systemd/journal/relinquished", now(CLOCK_MONOTONIC));
1297+
if (r < 0)
1298+
log_warning_errno(r, "Failed to write /run/systemd/journal/relinquished, ignoring: %m");
1299+
12981300
return 0;
12991301
}
13001302

0 commit comments

Comments
 (0)