Discussion:
delayed reply to sd-bus method invocation
(too old to reply)
Jason Litzinger
2017-06-29 02:52:49 UTC
Permalink
Raw Message
I have a daemon using the sd-bus API with a use case that I suspect
is supported, but wanted to see if there was an example anywhere (I've
been looking, haven't found one yet).

Is there a case in the systemd codebase (or something else) where a
method is invoked but its handler doesn't immediately reply?

What I'm trying to achieve is:

* method called
* Handler triggers some IO
<time passes>
* Important event occurs
* Reply message sent to the caller

I'm assuming this is possible/implemented, if not that would also be
good to know :).

Thanks in advance!
-Jason Litzinger
Lennart Poettering
2017-06-29 08:32:30 UTC
Permalink
Raw Message
Post by Jason Litzinger
I have a daemon using the sd-bus API with a use case that I suspect
is supported, but wanted to see if there was an example anywhere (I've
been looking, haven't found one yet).
Is there a case in the systemd codebase (or something else) where a
method is invoked but its handler doesn't immediately reply?
* method called
* Handler triggers some IO
<time passes>
* Important event occurs
* Reply message sent to the caller
I'm assuming this is possible/implemented, if not that would also be
good to know :).
PID 1 does this when a Reload() operation is issued as it will then
seriliaze its state, flush the configuration out, load the new
configuration and read the state back in. But following the codepaths
for this isn#t trivial.

machined has easier-to-follow uses of this, as it does some operations
that might take a bit longer, such as cloning or removing images.

Lennart
--
Lennart Poettering, Red Hat
Jason Litzinger
2017-06-30 03:55:18 UTC
Permalink
Raw Message
Post by Lennart Poettering
machined has easier-to-follow uses of this, as it does some operations
that might take a bit longer, such as cloning or removing images.
Thanks!

Since I'll be going through this to come up with something for my
own use case, it wouldn't be much to write up a self-contained example.
Is there an examples repo/folder/etc where this kind of thing would fit?

-Jason
Lennart Poettering
2017-07-03 08:36:04 UTC
Permalink
Raw Message
Post by Jason Litzinger
Post by Lennart Poettering
machined has easier-to-follow uses of this, as it does some operations
that might take a bit longer, such as cloning or removing images.
Thanks!
Since I'll be going through this to come up with something for my
own use case, it wouldn't be much to write up a self-contained example.
Is there an examples repo/folder/etc where this kind of thing would fit?
Not right now, no. We do have some terse examples in man pages though,
and maybe we can build on that. But to be included in a man page the
example needs to be reduced to the minimum, which isn't always easy.

Lennart
--
Lennart Poettering, Red Hat
Umut Tezduyar Lindskog
2017-07-03 12:31:14 UTC
Permalink
Raw Message
Hello Jason,

Just wanted to remind you that clients set a timeout for the method reply.
Don't remember off the top of my head but different implementations have
different default timeouts. Consider this when delaying the reply.

Umut
Post by Lennart Poettering
Post by Jason Litzinger
Post by Lennart Poettering
machined has easier-to-follow uses of this, as it does some operations
that might take a bit longer, such as cloning or removing images.
Thanks!
Since I'll be going through this to come up with something for my
own use case, it wouldn't be much to write up a self-contained example.
Is there an examples repo/folder/etc where this kind of thing would fit?
Not right now, no. We do have some terse examples in man pages though,
and maybe we can build on that. But to be included in a man page the
example needs to be reduced to the minimum, which isn't always easy.
Lennart
--
Lennart Poettering, Red Hat
_______________________________________________
systemd-devel mailing list
https://lists.freedesktop.org/mailman/listinfo/systemd-devel
Jason Litzinger
2017-07-04 03:07:31 UTC
Permalink
Raw Message
Post by Umut Tezduyar Lindskog
Hello Jason,
Just wanted to remind you that clients set a timeout for the method reply.
Don't remember off the top of my head but different implementations have
different default timeouts. Consider this when delaying the reply.
Thanks! I did run into that today, so this saved me some debugging.
The ultimate client in use is txdbus (I was testing with busctl today), so I'll
see how to change its timeout.

-Jason

Loading...