chiark / gitweb /
Add support for SD_BUS_DEFAULT*
authorNathaniel McCallum <npmccallum@redhat.com>
Mon, 22 Jan 2018 21:26:44 +0000 (16:26 -0500)
committerSven Eden <yamakuzure@gmx.net>
Wed, 30 May 2018 05:50:14 +0000 (07:50 +0200)
commit8b42f5e6cdc1c819741ef9492b7cec23971ccc4c
treee3596c5b52899b308cecfea1f945c5a2219a2bbe
parent269ddd6aecc9307853384bfc44a22c9ade596f34
Add support for SD_BUS_DEFAULT*

Currently, sd-bus supports the ability to have thread-local default busses.
However, this is less useful than it can be since all functions which
require an sd_bus* as input require the caller to pass it. This patch adds
a new macro which allows the developer to pass a constant SD_BUS_DEFAULT,
SD_BUS_DEFAULT_USER or SD_BUS_DEFAULT_SYSTEM instead. This reduces work for
the caller.

For example:

    r = sd_bus_default(&bus);
    r = sd_bus_call_method(bus, ...);
    sd_bus_unref(bus);

Becomes:

    r = sd_bus_call_method(SD_BUS_DEFAULT, ...);

If the specified thread-local default bus does not exist, the function
calls will return -ENOPKG. No bus will ever be implicitly created.
src/libelogind/sd-bus/bus-control.c
src/libelogind/sd-bus/bus-convenience.c
src/libelogind/sd-bus/bus-internal.h
src/libelogind/sd-bus/bus-objects.c
src/libelogind/sd-bus/bus-track.c
src/libelogind/sd-bus/sd-bus.c
src/systemd/sd-bus.h