summaryrefslogtreecommitdiff
path: root/src/libsystemd-bus/sd-bus.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-10-11 19:33:39 +0200
committerLennart Poettering <lennart@poettering.net>2013-10-11 20:03:19 +0200
commit43a43f5016eb9404afdd6719b18f604a484535ec (patch)
treeb9b693e25083913f9129291bee54749c5fdbc97c /src/libsystemd-bus/sd-bus.c
parent1a0464230c08506c3fd715ff7cc56660df3a85ca (diff)
bus: automatically do a NOP reply when a NULL callback is specified for a method in a vtable
Also, allow specifiying NULL as signature in vtables equivalent to "" for empty parameter lists.
Diffstat (limited to 'src/libsystemd-bus/sd-bus.c')
-rw-r--r--src/libsystemd-bus/sd-bus.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/libsystemd-bus/sd-bus.c b/src/libsystemd-bus/sd-bus.c
index 1d8d569429..3fd5186763 100644
--- a/src/libsystemd-bus/sd-bus.c
+++ b/src/libsystemd-bus/sd-bus.c
@@ -2100,7 +2100,15 @@ static int method_callbacks_run(
return 1;
}
- return c->vtable->method.handler(bus, m, u);
+ if (c->vtable->method.handler)
+ return c->vtable->method.handler(bus, m, u);
+
+ /* If the method callback is NULL, make this a successful NOP */
+ r = sd_bus_reply_method_return(bus, m, NULL);
+ if (r < 0)
+ return r;
+
+ return 1;
}
static int invoke_property_get(
@@ -3761,7 +3769,7 @@ static int add_object_vtable_internal(
if (!member_name_is_valid(v->method.member) ||
!signature_is_valid(v->method.signature, false) ||
!signature_is_valid(v->method.result, false) ||
- !v->method.handler ||
+ !(v->method.handler || (isempty(v->method.signature) && isempty(v->method.result))) ||
v->flags & (SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE|SD_BUS_VTABLE_PROPERTY_INVALIDATE_ONLY)) {
r = -EINVAL;
goto fail;