Raw libdbus dispatching

Havoc Pennington hp at redhat.com
Tue Oct 24 10:22:01 PDT 2006


Peter Clifton wrote:
> 
> Lesstif only supports file IO watches which are Read, Write and
> Exception. (HUP is not listed). I'm not sure how to map the dbus request
> flags onto Lesstif. Do I need to manually re-poll the file-descriptor
> inside my Lesstif callback to check for HUP?
>

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.

> Dispatching:
> 
> The glib bindings use a custom GSource to dispatch at most one message
> per mainloop iteration if there are messages pending. Lesstif doesn't
> have a comparible source mechanism. It has Idle work functions (which I
> don't want to use, as it will spin CPU time). It has a "block_hook",
> which looks useful.. it can call your callback before it blocks in the
> mainloop's poll or select function. I could also add a timeout to fire
> periodically, but that doesn't seem like a clean solution.
> 
> Does dispatching a single message before the mainloop blocks ensure that
> we won't get locked up waiting for IO?

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.

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.

Havoc



More information about the dbus mailing list