[systemd-devel] [PATCH] libsystemd-bus: Add return error msg for unicast signals when well-known name is not available

Lennart Poettering lennart at poettering.net
Tue Dec 10 11:24:51 PST 2013


On Wed, 04.12.13 14:44, Lukasz Skalski (l.skalski at partner.samsung.com) wrote:

> ENXIO, ESRCH and EADDRNOTAVAIL are also returned by ioctl(KDBUS_CMD_MSG_SEND)
> when we have unicast signal messages (signals with a DESTINATION
> field).

Well, but you cannot respond to signals. They are supposed to be these
one-time things you send out, where no response is coming back. Method
calls otoh are supposed to have responses where either method success or
method failure is returned.

The code in question will generate an error reply for method calls on
failure, but simply eat up the error when sending a signal fails. Which
is the right thing to do...

> ---
>  src/libsystemd-bus/bus-kernel.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/libsystemd-bus/bus-kernel.c b/src/libsystemd-bus/bus-kernel.c
> index b85a10d..1499830 100644
> --- a/src/libsystemd-bus/bus-kernel.c
> +++ b/src/libsystemd-bus/bus-kernel.c
> @@ -414,7 +414,7 @@ int bus_kernel_write_message(sd_bus *bus, sd_bus_message *m) {
>                          /* ENXIO: unique name not known
>                           * ESRCH: well-known name not known */
>  
> -                        if (m->header->type == SD_BUS_MESSAGE_METHOD_CALL)
> +                        if (m->header->type == SD_BUS_MESSAGE_METHOD_CALL || m->header->type == SD_BUS_MESSAGE_SIGNAL)
>                                  sd_bus_error_setf(&error, SD_BUS_ERROR_SERVICE_UNKNOWN, "Destination %s not known", m->destination);
>                          else
>                                  return 0;
> @@ -423,7 +423,7 @@ int bus_kernel_write_message(sd_bus *bus, sd_bus_message *m) {
>  
>                          /* EADDRNOTAVAIL: activation is possible, but turned off in request flags */
>  
> -                        if (m->header->type == SD_BUS_MESSAGE_METHOD_CALL)
> +                        if (m->header->type == SD_BUS_MESSAGE_METHOD_CALL || m->header->type == SD_BUS_MESSAGE_SIGNAL)
>                                  sd_bus_error_setf(&error, SD_BUS_ERROR_SERVICE_UNKNOWN, "Activation of %s not requested", m->destination);
>                          else
>                                  return 0;


Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list