unit: shortcut unit_notify() early, if possible
This commit is contained in:
parent
37d88da701
commit
a90ebccc07
3
device.c
3
device.c
|
@ -49,6 +49,9 @@ static void device_set_state(Device *d, DeviceState state) {
|
|||
DeviceState old_state;
|
||||
assert(d);
|
||||
|
||||
if (state == d->state)
|
||||
return;
|
||||
|
||||
old_state = d->state;
|
||||
d->state = state;
|
||||
|
||||
|
|
|
@ -968,6 +968,9 @@ static void service_set_state(Service *s, ServiceState state) {
|
|||
state == SERVICE_AUTO_RESTART)
|
||||
service_notify_sockets(s);
|
||||
|
||||
if (old_state == state)
|
||||
return;
|
||||
|
||||
log_debug("%s changed %s → %s", unit_id(UNIT(s)), service_state_to_string(old_state), service_state_to_string(state));
|
||||
|
||||
unit_notify(UNIT(s), state_translation_table[old_state], state_translation_table[state]);
|
||||
|
|
3
socket.c
3
socket.c
|
@ -391,6 +391,9 @@ static void socket_set_state(Socket *s, SocketState state) {
|
|||
if (state != SOCKET_LISTENING)
|
||||
socket_unwatch_fds(s);
|
||||
|
||||
if (state == old_state)
|
||||
return;
|
||||
|
||||
log_debug("%s changed %s → %s", unit_id(UNIT(s)), state_string_table[old_state], state_string_table[state]);
|
||||
|
||||
unit_notify(UNIT(s), state_translation_table[old_state], state_translation_table[state]);
|
||||
|
|
Loading…
Reference in a new issue