[systemd-commits] 2 commits - src/bus-driverd
Lennart Poettering
lennart at kemper.freedesktop.org
Tue Dec 17 11:42:10 PST 2013
src/bus-driverd/bus-driverd.c | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
New commits:
commit c966ef4a7678c4040884a5e644132660e72cd6d9
Author: Lennart Poettering <lennart at poettering.net>
Date: Tue Dec 17 20:39:15 2013 +0100
bus: properly return an error code when release_name fails abnormally
diff --git a/src/bus-driverd/bus-driverd.c b/src/bus-driverd/bus-driverd.c
index a1ad050..ccb1fb3 100644
--- a/src/bus-driverd/bus-driverd.c
+++ b/src/bus-driverd/bus-driverd.c
@@ -333,8 +333,7 @@ static int driver_request_name(sd_bus *bus, sd_bus_message *m, void *userdata, s
size = sizeof(*cmd_name) + strlen(name) + 1;
- cmd_name = alloca(size);
- memset(cmd_name, 0, size);
+ cmd_name = alloca0(size);
strcpy(cmd_name->name, name);
cmd_name->size = size;
kdbus_translate_request_name_flags(flags, (uint64_t *) &cmd_name->conn_flags);
@@ -353,8 +352,8 @@ static int driver_request_name(sd_bus *bus, sd_bus_message *m, void *userdata, s
return sd_bus_reply_method_return(m, "u", BUS_NAME_EXISTS);
else if (errno == EALREADY)
return sd_bus_reply_method_return(m, "u", BUS_NAME_ALREADY_OWNER);
- else
- return sd_bus_reply_method_return(m, "u", -errno);
+
+ return -errno;
}
if (cmd_name->flags & KDBUS_NAME_IN_QUEUE)
commit 3263ef39b89080cacccaf9b7b36675490a282f2d
Author: Lukasz Skalski <l.skalski at partner.samsung.com>
Date: Tue Dec 17 17:31:46 2013 +0100
bus-driverd: Fix return code in driver_request_name
RequestName return codes should be consistent with Dbus Specification.
VALUE - DESCRIPTION
1-The caller is now the primary owner of the name, replacing any previous owner,
2-The name already had an owner (QUEUE flag was not specified),
3-The name already has an owner (QUEUE flag was specified),
4-Application trying to request ownership of a name is already the owner of it.
diff --git a/src/bus-driverd/bus-driverd.c b/src/bus-driverd/bus-driverd.c
index 11bd2f9..a1ad050 100644
--- a/src/bus-driverd/bus-driverd.c
+++ b/src/bus-driverd/bus-driverd.c
@@ -348,10 +348,19 @@ static int driver_request_name(sd_bus *bus, sd_bus_message *m, void *userdata, s
cmd_name->id = id;
r = ioctl(sd_bus_get_fd(bus), KDBUS_CMD_NAME_ACQUIRE, cmd_name);
- if (r < 0)
- return r;
+ if (r < 0) {
+ if (errno == EEXIST)
+ return sd_bus_reply_method_return(m, "u", BUS_NAME_EXISTS);
+ else if (errno == EALREADY)
+ return sd_bus_reply_method_return(m, "u", BUS_NAME_ALREADY_OWNER);
+ else
+ return sd_bus_reply_method_return(m, "u", -errno);
+ }
+
+ if (cmd_name->flags & KDBUS_NAME_IN_QUEUE)
+ return sd_bus_reply_method_return(m, "u", BUS_NAME_IN_QUEUE);
- return sd_bus_reply_method_return(m, "u", 0);
+ return sd_bus_reply_method_return(m, "u", BUS_NAME_PRIMARY_OWNER);
}
static int driver_start_service_by_name(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bus_error *error) {
More information about the systemd-commits
mailing list