mirror of
https://github.com/morgan9e/systemd
synced 2026-04-14 08:25:20 +09:00
mute-console: don't unmute twice when not running as varlink service
This also avoids the spurious "not restoring" logs if we fail to dispatch varlink call.
This commit is contained in:
@@ -248,28 +248,6 @@ static int unmute_kernel(Context *c) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void context_done(Context *c) {
|
||||
assert(c);
|
||||
|
||||
(void) unmute_pid1(c);
|
||||
(void) unmute_kernel(c);
|
||||
|
||||
if (c->link) {
|
||||
(void) sd_varlink_set_userdata(c->link, NULL);
|
||||
c->link = sd_varlink_flush_close_unref(c->link);
|
||||
}
|
||||
}
|
||||
|
||||
static Context* context_free(Context *c) {
|
||||
if (!c)
|
||||
return NULL;
|
||||
|
||||
context_done(c);
|
||||
return mfree(c);
|
||||
}
|
||||
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(Context*, context_free);
|
||||
|
||||
static void vl_on_disconnect(sd_varlink_server *server, sd_varlink *link, void *userdata) {
|
||||
assert(link);
|
||||
|
||||
@@ -277,7 +255,13 @@ static void vl_on_disconnect(sd_varlink_server *server, sd_varlink *link, void *
|
||||
if (!c)
|
||||
return;
|
||||
|
||||
context_free(c);
|
||||
(void) unmute_pid1(c);
|
||||
(void) unmute_kernel(c);
|
||||
|
||||
(void) sd_varlink_set_userdata(c->link, NULL);
|
||||
sd_varlink_flush_close_unref(c->link);
|
||||
|
||||
free(c);
|
||||
}
|
||||
|
||||
static int vl_method_mute(
|
||||
@@ -290,7 +274,7 @@ static int vl_method_mute(
|
||||
|
||||
assert(link);
|
||||
|
||||
_cleanup_(context_freep) Context *nc = new(Context, 1);
|
||||
_cleanup_free_ Context *nc = new(Context, 1);
|
||||
if (!nc)
|
||||
return -ENOMEM;
|
||||
|
||||
@@ -384,7 +368,7 @@ static int run(int argc, char* argv[]) {
|
||||
if (!arg_mute_pid1 && !arg_mute_kernel)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Not asked to mute anything, refusing.");
|
||||
|
||||
_cleanup_(context_done) Context c = {
|
||||
Context c = {
|
||||
.mute_pid1 = arg_mute_pid1,
|
||||
.mute_kernel = arg_mute_kernel,
|
||||
.saved_kernel = -1,
|
||||
|
||||
Reference in New Issue
Block a user