]> git.ipfire.org Git - thirdparty/systemd.git/commit
sd-varlink: Introduce varlink_set_sentinel()
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 2 Feb 2026 13:23:40 +0000 (14:23 +0100)
committerDaan De Meyer <daan@amutable.com>
Wed, 11 Feb 2026 13:24:03 +0000 (14:24 +0100)
commitc0696f1f5d3a2be1c8e4c8b45ca7e8a6df7998fa
treeb4497f135caae08e9e44f286a362f3105062329c
parent22f1d5a625e3c54e5f114a286a7700d74db39770
sd-varlink: Introduce varlink_set_sentinel()

Streaming methods which are not used as a continuous subscription but
instead only send a series of objects all end up with the same workaround
to be able to figure out when to send sd_varlink_reply() or sd_varlink_notify().
Let's generalize this in sd-varlink itself.

Let's introduce the concept of a sentinel, which is a reply that will be sent
by sd-varlink if no other reply was queued by a method callback. The sentinel
is configured with varlink_set_sentinel(). If a sentinel is configured,
sd_varlink_reply() can be used more than once in streaming methods to queue
multiple values to stream to the client. The last queued reply is not sent
until the callback finishes. When the callback finishes, the last reply is
sent without "continues: more". If no reply was queued, the sentinel is sent.

This always using only sd_varlink_reply() in such streaming methods and
leaves sd_varlink_notify() available solely for continuous subscription
streaming methods, where we never use sd_varlink_reply() and instead disconnect
when the server exits.
src/libsystemd/sd-varlink/sd-varlink.c
src/libsystemd/sd-varlink/varlink-internal.h
src/libsystemd/sd-varlink/varlink-util.c
src/libsystemd/sd-varlink/varlink-util.h
src/test/test-varlink.c