From: Lennart Poettering Date: Tue, 23 Jul 2019 08:22:24 +0000 (+0200) Subject: logind: unify inhibitor signal generation in a single function X-Git-Tag: v243-rc1~56^2~7 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=fa39c2de5b5552ffe804d1a5ae9b64dae8c72152;p=thirdparty%2Fsystemd.git logind: unify inhibitor signal generation in a single function --- diff --git a/src/login/logind-inhibit.c b/src/login/logind-inhibit.c index 3bb04a5d31a..773a7ee008a 100644 --- a/src/login/logind-inhibit.c +++ b/src/login/logind-inhibit.c @@ -143,6 +143,16 @@ fail: return log_error_errno(r, "Failed to save inhibit data %s: %m", i->state_file); } +static int bus_manager_send_inhibited_change(Inhibitor *i) { + const char *property; + + assert(i); + + property = i->mode == INHIBIT_BLOCK ? "BlockInhibited" : "DelayInhibited"; + + return manager_send_changed(i->manager, property, NULL); +} + int inhibitor_start(Inhibitor *i) { assert(i); @@ -156,11 +166,11 @@ int inhibitor_start(Inhibitor *i) { i->pid, i->uid, inhibit_mode_to_string(i->mode)); - inhibitor_save(i); - i->started = true; - manager_send_changed(i->manager, i->mode == INHIBIT_BLOCK ? "BlockInhibited" : "DelayInhibited", NULL); + inhibitor_save(i); + + bus_manager_send_inhibited_change(i); return 0; } @@ -179,7 +189,7 @@ int inhibitor_stop(Inhibitor *i) { i->started = false; - manager_send_changed(i->manager, i->mode == INHIBIT_BLOCK ? "BlockInhibited" : "DelayInhibited", NULL); + bus_manager_send_inhibited_change(i); return 0; }