dm0 / rpms / systemd

Forked from rpms/systemd 5 years ago
Clone
Blob Blame History Raw
From db97c7f66ef2f75ac6c268339e044590d7a08920 Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Wed, 24 Apr 2013 15:23:01 -0300
Subject: [PATCH] logind: don't busy loop if a job is still running but the
 delay timeout expires (cherry picked from commit
 842865365e598a090045894f8990fd384e801ccb)

---
 src/core/dbus-job.c     | 17 +++++++----------
 src/login/logind-dbus.c |  3 +--
 src/login/logind.c      |  2 +-
 3 files changed, 9 insertions(+), 13 deletions(-)

diff --git a/src/core/dbus-job.c b/src/core/dbus-job.c
index 096542b..98ccfa6 100644
--- a/src/core/dbus-job.c
+++ b/src/core/dbus-job.c
@@ -218,7 +218,7 @@ const DBusObjectPathVTable bus_job_vtable = {
 };
 
 static int job_send_message(Job *j, DBusMessage* (*new_message)(Job *j)) {
-        DBusMessage *m = NULL;
+        _cleanup_dbus_message_unref_ DBusMessage *m = NULL;
         int r;
 
         assert(j);
@@ -227,9 +227,9 @@ static int job_send_message(Job *j, DBusMessage* (*new_message)(Job *j)) {
         if (bus_has_subscriber(j->manager) || j->forgot_bus_clients) {
                 m = new_message(j);
                 if (!m)
-                        goto oom;
+                        return -ENOMEM;
+
                 r = bus_broadcast(j->manager, m);
-                dbus_message_unref(m);
                 if (r < 0)
                         return r;
 
@@ -238,18 +238,19 @@ static int job_send_message(Job *j, DBusMessage* (*new_message)(Job *j)) {
                  * to the client(s) which created the job */
                 JobBusClient *cl;
                 assert(j->bus_client_list);
+
                 LIST_FOREACH(client, cl, j->bus_client_list) {
                         assert(cl->bus);
 
                         m = new_message(j);
                         if (!m)
-                                goto oom;
+                                return -ENOMEM;
 
                         if (!dbus_message_set_destination(m, cl->name))
-                                goto oom;
+                                return -ENOMEM;
 
                         if (!dbus_connection_send(cl->bus, m, NULL))
-                                goto oom;
+                                return -ENOMEM;
 
                         dbus_message_unref(m);
                         m = NULL;
@@ -257,10 +258,6 @@ static int job_send_message(Job *j, DBusMessage* (*new_message)(Job *j)) {
         }
 
         return 0;
-oom:
-        if (m)
-                dbus_message_unref(m);
-        return -ENOMEM;
 }
 
 static DBusMessage* new_change_signal_message(Job *j) {
diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c
index 775a50f..2c7813a 100644
--- a/src/login/logind-dbus.c
+++ b/src/login/logind-dbus.c
@@ -2380,7 +2380,6 @@ DBusHandlerResult bus_message_filter(
                         log_error("Failed to parse JobRemoved message: %s", bus_error_message(&error));
 
                 else if (m->action_job && streq(m->action_job, path)) {
-
                         log_info("Operation finished.");
 
                         /* Tell people that they now may take a lock again */
@@ -2421,7 +2420,7 @@ int manager_dispatch_delayed(Manager *manager) {
 
         assert(manager);
 
-        if (!manager->action_unit || manager->action_job)
+        if (manager->action_what == 0 || manager->action_job)
                 return 0;
 
         /* Continue delay? */
diff --git a/src/login/logind.c b/src/login/logind.c
index 2bad122..7f87133 100644
--- a/src/login/logind.c
+++ b/src/login/logind.c
@@ -1625,7 +1625,7 @@ int manager_run(Manager *m) {
 
                 manager_gc(m, true);
 
-                if (m->action_what != 0) {
+                if (m->action_what != 0 && !m->action_job) {
                         usec_t x, y;
 
                         x = now(CLOCK_MONOTONIC);