chiark / gitweb /
core: when an already abandoned unit gets abandoned again generate a clean error
authorLennart Poettering <lennart@poettering.net>
Fri, 7 Feb 2014 16:59:27 +0000 (17:59 +0100)
committerLennart Poettering <lennart@poettering.net>
Fri, 7 Feb 2014 18:26:49 +0000 (19:26 +0100)
TODO
src/core/dbus-scope.c
src/login/logind-dbus.c
src/shared/bus-errors.h

diff --git a/TODO b/TODO
index 57e82ff..b9a0f0f 100644 (file)
--- a/TODO
+++ b/TODO
@@ -36,6 +36,8 @@ External:
 
 Features:
 
+* nspawn: rename --file-label to --apifs-label
+
 * hookup nspawn and PrivateNetwork=yes with "ip netns"
 
 * socket units: support creating sockets in different namespace,
index c46c972..d025696 100644 (file)
 #include "dbus-scope.h"
 #include "bus-util.h"
 #include "bus-internal.h"
+#include "bus-errors.h"
 
 static int bus_scope_abandon(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
         Scope *s = userdata;
+        int r;
 
         assert(bus);
         assert(message);
         assert(s);
 
-        return scope_abandon(s);
+        r = scope_abandon(s);
+        if (sd_bus_error_is_set(error))
+                return r;
+
+        if (r == -ESTALE)
+                return sd_bus_error_setf(error, BUS_ERROR_SCOPE_NOT_RUNNING, "Scope %s is not running, cannot abandon.", UNIT(s)->id);
+
+        return sd_bus_reply_method_return(message, NULL);
 }
 
 static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_result, scope_result, ScopeResult);
index 30476f3..651bd80 100644 (file)
@@ -2384,7 +2384,8 @@ int manager_abandon_scope(Manager *manager, const char *scope, sd_bus_error *err
                         NULL);
         if (r < 0) {
                 if (sd_bus_error_has_name(error, BUS_ERROR_NO_SUCH_UNIT) ||
-                    sd_bus_error_has_name(error, BUS_ERROR_LOAD_FAILED)) {
+                    sd_bus_error_has_name(error, BUS_ERROR_LOAD_FAILED) ||
+                    sd_bus_error_has_name(error, BUS_ERROR_SCOPE_NOT_RUNNING)) {
                         sd_bus_error_free(error);
                         return 0;
                 }
index e9ab731..5637935 100644 (file)
@@ -37,6 +37,7 @@
 #define BUS_ERROR_JOB_TYPE_NOT_APPLICABLE "org.freedesktop.systemd1.JobTypeNotApplicable"
 #define BUS_ERROR_NO_ISOLATION "org.freedesktop.systemd1.NoIsolation"
 #define BUS_ERROR_SHUTTING_DOWN "org.freedesktop.systemd1.ShuttingDown"
+#define BUS_ERROR_SCOPE_NOT_RUNNING "org.freedesktop.systemd1.ScopeNotRunning"
 
 #define BUS_ERROR_NO_SUCH_MACHINE "org.freedesktop.machine1.NoSuchMachine"
 #define BUS_ERROR_NO_MACHINE_FOR_PID "org.freedesktop.machine1.NoMachineForPID"