Problems with dbus_connection_borrow_message

Simon McVittie simon.mcvittie at collabora.co.uk
Tue Feb 24 08:12:44 PST 2015


On 24/02/15 15:03, itchy_2390 wrote:
> I think I got a little bit further If I call
> dbus_connection_read_write_dispatch instead of dbus_connection_read_write I
> get the signals. But I'm not sure I understand the difference between these
> two functions.

It's very simple, one of them dispatches and the other one doesn't :-)
But I realise it isn't entirely obvious what "dispatch" means.

"read_write" in this context means doing the actual socket I/O: writing 
outgoing messages to the socket until the buffer is full or there is 
nothing more to write, and putting incoming messages in a queue inside 
the DBusConnection until a limit is reached or there is nothing more to 
read.

"dispatch" means draining that queue by handing out messages to their 
correct recipients: DBusPendingCall objects that expect replies for 
outgoing method calls, the filter functions that I recommended you 
should use for signals, and object-path handlers for incoming method calls.

Popping/borrowing/stealing messages from the connection takes them off 
the queue directly, bypassing the dispatching code. You probably don't 
want that: even the dbus-daemon and the dbus-monitor tool don't do that 
(they use filters), and they're quite low-level themselves.

-- 
Simon McVittie
Collabora Ltd. <http://www.collabora.com/>



More information about the dbus mailing list