Re: sd_bus_process semantics

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mo, 25.07.22 12:21, Mathis MARION (mamarion1@xxxxxxxxxx) wrote:

> I looked a bit into the source code:
>
> This part is responsible for storing the message processed in *ret:
>
> static int process_running(sd_bus *bus, sd_bus_message **ret) {
> [...]
>         r = process_message(bus, m);
>         if (r != 0)
>                 goto null_message;
>
>         if (ret) {
>                 r = sd_bus_message_rewind(m, true);
>                 if (r < 0)
>                         return r;
>
>                 *ret = TAKE_PTR(m);
>                 return 1;
>         }
> [...]
> null_message:
>         if (r >= 0 && ret)
>                 *ret = NULL;
>
>         return r;
> }
>
> static int process_message(sd_bus *bus, sd_bus_message *m) {
> [...]
>         r = process_hello(bus, m);
>         if (r != 0)
>                 goto finish;
> [...]
>         r = process_builtin(bus, m);
>         if (r != 0)
>                 goto finish;
>
>         r = bus_process_object(bus, m);
>
> finish:
>         bus->current_message = NULL;
>         return r;
> }
>
> My analysis might be flawed since I am still new to sd-bus, but to me it
> seems like 'process_message' should return 0 on success, but since
> 'bus_process_object' returns 0 on failure it does not quite work as
> intended.

So, the idea is that sd_bus_process() only returns a message that
otherwise nothing was interested in processing. i.e. if you add a
filter or object handler or so, and it decided to process a message
(and thus returned 1 in its handler) then the message is considered
processed and not processed further, and thus not propagated back to
the caller. Only messages that no registered handler has indicated
"ownership" in will be returned to the caller.

I guess we should document that. Added to TODO list.

Th idea is basically that you have two choices for processing
messages: install a filter/handler, or process them via
sd_bus_process() returns. Pick one.

Lennart

--
Lennart Poettering, Berlin



[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux