diff options
Diffstat (limited to 'src/libsystemd-bus')
-rw-r--r-- | src/libsystemd-bus/sd-bus.c | 12 | ||||
-rw-r--r-- | src/libsystemd-bus/test-bus-objects.c | 6 |
2 files changed, 14 insertions, 4 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; diff --git a/src/libsystemd-bus/test-bus-objects.c b/src/libsystemd-bus/test-bus-objects.c index 06947a2c18..637e0511b2 100644 --- a/src/libsystemd-bus/test-bus-objects.c +++ b/src/libsystemd-bus/test-bus-objects.c @@ -39,8 +39,6 @@ * Add in: * * automatic properties for Set() - * automatic NULL method - * allow NULL as signatures in vtable * node hierarchy updates during dispatching * emit_interfaces_added/emit_interfaces_removed * @@ -157,6 +155,7 @@ static const sd_bus_vtable vtable[] = { SD_BUS_WRITABLE_PROPERTY("Something", "s", get_handler, set_handler, 0, 0), SD_BUS_PROPERTY("AutomaticStringProperty", "s", NULL, offsetof(struct context, automatic_string_property), 0), SD_BUS_PROPERTY("AutomaticIntegerProperty", "u", NULL, offsetof(struct context, automatic_integer_property), 0), + SD_BUS_METHOD("NoOperation", "", "", NULL, 0), SD_BUS_VTABLE_END }; @@ -241,6 +240,9 @@ static int client(struct context *c) { assert_se(sd_bus_set_fd(bus, c->fds[1], c->fds[1]) >= 0); assert_se(sd_bus_start(bus) >= 0); + r = sd_bus_call_method(bus, "org.freedesktop.systemd.test", "/foo", "org.freedesktop.systemd.test", "NoOperation", &error, NULL, NULL); + assert_se(r >= 0); + r = sd_bus_call_method(bus, "org.freedesktop.systemd.test", "/foo", "org.freedesktop.systemd.test", "AlterSomething", &error, &reply, "s", "hallo"); assert_se(r >= 0); |