]> err.no Git - systemd/commitdiff
unit: shortcut unit_notify() early, if possible
authorLennart Poettering <lennart@poettering.net>
Thu, 8 Apr 2010 01:01:05 +0000 (03:01 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 8 Apr 2010 01:01:05 +0000 (03:01 +0200)
device.c
service.c
socket.c
target.c

index 25661e05f80840a579f54e1fa41f71a8050292b9..d99038f77e72fb3c367468b9b9b943e18f05d623 100644 (file)
--- a/device.c
+++ b/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;
 
index 7ed9783f796c2786fe7c402dc9df122efea3f8fb..74d03dbe1d4c26693b7db0ddc4049b08386e7cc1 100644 (file)
--- a/service.c
+++ b/service.c
@@ -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]);
index 4e3522505f4ba3d34e675e7509fe8d7b7c9a89c3..617a49a07509abe2eaf6310bb164d420adc129a3 100644 (file)
--- a/socket.c
+++ b/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]);
index b8a7442f1c44b39100bf8f0678ab42c2a3c29d7e..c80c09d546b62a46bb97bcb3d65a99a850971443 100644 (file)
--- a/target.c
+++ b/target.c
@@ -52,6 +52,9 @@ static void target_set_state(Target *t, TargetState state) {
         TargetState old_state;
         assert(t);
 
+        if (state == t->state)
+                return;
+
         old_state = t->state;
         t->state = state;