Integrating a DBus listener with libevent framework

Philip Prindeville philipp_subx at redfish-solutions.com
Tue Aug 23 22:31:31 UTC 2016


Hi,

I've been asked to take a daemon which implements a protocol proxy (kind 
of like an ALG, if that matters) and add a DBus interface to it.

Most of the examples I've looked at for DBus were based on a main loop 
that DBus would consume messages and invoke its handler.

In this case, the daemon is single-threaded but event-driven (via 
libevent) since none of the handling of the events ever requires any 
sort of blocking.

I know of a lot of programs using DBus and libevent (and even a few 
using both together) but when I googled for a good example of having 
DBus be driven from the libevent dispatcher, I only found a couple of 
examples and both had issues.

I can't believe that no one has handled this issue and gotten it "right" 
by now, so I thought I'd reach out to the mailing list and asked.

I figure it shouldn't be more than a couple of pages of "glue" to get 
DBus humming along happily on top of libevent... but maybe I'm being naive.

I found dbus-service on github but that seemed to have an unresolved 
race condition.  It's also not particularly recent, so it doesn't build 
on libevent 2.0 or later.

I also saw this example on stackoverflow:

http://stackoverflow.com/questions/9378593/dbuswatch-and-dbustimeout-examples

but it was a bit rough.

Can anyone point me at some useful examples?

Thanks,

-Philip



More information about the dbus mailing list