Raw libdbus dispatching

Peter Clifton pcjc2 at cam.ac.uk
Tue Oct 24 13:32:34 PDT 2006


[POSTING BACK TO THE DBUS LIST, AS I ACCIDENTALLY REPLIED DIRECTLY TO
HAVOC]

[snip]
> I don't think libdbus cares about hup right now in practice, so you 
> could just ignore the issue. But yes you'd probably have to manually 
> re-poll, or not use the lesstif file watches.

Have done it by re-polling.. wasn't so painful in the end.

[snip]

> dbus will never block unless you call one of the blocking functions 
> (which you should not need to do here - all IO can be in 
> dbus_watch_handle())
>
> The thing you need to worry about is going to sleep with stuff not
yet 
> dispatched, which means you wouldn't get the message until you
happened 
> to get another message to wake you up. So e.g. you can set a dispatch 
> status function and then be sure you add a one-shot idle work
function 
> that dispatches until there is nothing more to dispatch, maybe.

I'd completely missed "dbus_connection_set_dispatch_status_function()"!
Looks like that may be very useful.

It currently "seems" to work if I dispatch one message before the
mainloop blocks. (If I don't dispatch messages there, things just don't
get sent and dbus stops working for the app).

Still, if there are two or more messages in need of dispatching, I
dispatch one, then let the mainloop block, am I just relying on X-events
etc... to break the block before DBUS can continue? Is that risky... I
could dispatch _all_ dbus messages before the mainloop blocks, I just
didn't want it to starve the mainloop (there is a comment about that in
the glib bindings).

Can dbus_connection_dispatch() block?

Also, while I'm asking silly questions:

I don't know what to do with:
dbus_connection_set_wakeup_main_function(). I know it can map to
g_main_context_wakeup() in glib, but I'm not really sure what it is
supposed to do. I certainly can't think how it maps to lesstif.

Is it for threaded apps? The app I'm working on seems to be fine without
it, but I thought I'd check.

> btw I improved the Doxygen docs on all this a fair bit the other day, 
> though they are still definitely reference/api docs and not 
> tutorial/overview.

Indeed, the dbus docs appear to be best read in conjunction with the
source, especially for other apps and bindings. The thought
"bootstrapping problem" sprang to mind there :).

Is the doxygen manual at 
http://dbus.freedesktop.org/doc/dbus/api/html/group__DBusConnection.html

updated, or is it just in CVS?


Thanks for your fantastic help,

Regards

-- 
Peter Clifton

Electrical Engineering Division,
Engineering Department,
University of Cambridge,
9, JJ Thomson Avenue,
Cambridge
CB3 0FA

Tel: +44 (0)7729 980173



More information about the dbus mailing list