1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-12-25 23:21:33 +03:00

core: when an already abandoned unit gets abandoned again generate a clean error

This commit is contained in:
Lennart Poettering 2014-02-07 17:59:27 +01:00
parent ba4c5d93b7
commit 4e2f8d2778
4 changed files with 15 additions and 2 deletions

2
TODO
View File

@ -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,

View File

@ -27,15 +27,24 @@
#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);

View 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;
}

View 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"