mirror of
https://github.com/systemd/systemd-stable.git
synced 2024-10-27 01:55:32 +03:00
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.
This commit is contained in:
parent
1a0464230c
commit
43a43f5016
2
TODO
2
TODO
@ -182,9 +182,7 @@ Features:
|
||||
- merge busctl into systemctl or so?
|
||||
- synthesize sd_bus_message objects from kernel messages
|
||||
- properly implement name registry ioctls for kdbus
|
||||
- get rid of object hash table, use decision tree everyhwere instead?
|
||||
- implement monitor logic
|
||||
- object vtable logic
|
||||
- longer term:
|
||||
* priority queues
|
||||
* priority inheritance
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user