[systemd-devel] Multicast signaling with sd-bus questions

Gorman, Brian (Vancouver) bgorman at hp.com
Thu Jan 7 16:37:44 PST 2016


Hi all, I am in the process of considering using sd-bus to coordinate a system-wide multicast messaging system between daemons. At this time I only have resources to look into using libsystemd without system running. It seems the sd-bus documentation is very sparse compared to sd-event - does this mean sd-bus is more immature?

My initial goal is to be able to select() on dbus-signals. Unfortunately my dbus experience is quite minimal, and I am not sure what this will take. Here is my initial attempt adapted from Lennarts tutorial - I have no idea if this is the right approach I was hoping if this list could perhaps provide some guidance as I suspect I am doing a few things wrong.

int main(int argc, char *argv[]) {
    sd_bus_slot *slot = NULL;
    sd_bus *bus = NULL;
    int r;
    int fd;
    fd_set rd_fdset;
    int my_user_data;

    /* Connect to the system bus this time */
    r = sd_bus_open_system(&bus);
    if (r < 0) {
        fprintf(stderr, "Failed to connect to bus: %s\n", strerror(-r));
        goto finish;
    }
        r = sd_bus_request_name(bus, "Test.Me", 0);
        if (r < 0) {
                fprintf(stderr, "Failed to acquire service name: %s\n", strerror(-r));
                goto finish;
        }

    r = sd_bus_add_match(
            bus,
            slot,
            "type='signal',"
            "sender='testsignal',"
            "interface='Japan.Reset',"
            "member='Test',"
            "path='/Japan'",
            my_signal_callback,
            my_user_data);

    fd = sd_bus_get_fd(bus);
    if (fd < 0)
        assert(0);
    FD_ZERO(&rd_fdset);
    FD_SET(fd, &rd_fdset);
    for (;;) {
select(fd +1, &rd_fdset, NULL, NULL,NULL);
            r = sd_bus_process(bus, NULL);
            if (r < 0) {
                    fprintf(stderr, "Failed to process bus: %s\n", strerror(-r));
                    goto finish;
            }
    }

>From here I was hoping to run something like "dbus-send -system -dest=Test.Me -print-reply /Japan Japan.Reset.Test string:"Hello""

It currently get errors about DBUs complaining that Test.Me was not provided in any .service files when executing the above command. Any suggestion how to get around that issue would be helpful. My initial attempt at copying:
http://kkaempf.blogspot.com/2009/03/d-bus-service-on-demand.html to create a ini file was was unsuccessful. It seems busctl cannot send signals?

Regards,

Brian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20160108/38ae8dd0/attachment.html>


More information about the systemd-devel mailing list