GNOME Bugzilla – Bug 618882
No way to ensure that a message is sent
Last modified: 2010-07-07 19:04:43 UTC
near as i can tell, there is no way to ensure that a GDBus message has been sent unless you wait for the reply. this is a problem for commandline tools like "gsettings set" that just send the message off and exit immediately without running the mainloop and without allowing a chance for the worker thread to do the work for sending the message off. in libdbus we have a flush() method on the connection to handle this. perhaps we could have this in GDBus too? perhaps we could have a somewhat higher-level API for this? in some ways this could be consider a GSettings bug; in fact, i very nearly added a g_settings_sync() API to wait until all outstanding writes had come back, but i think it would be generally useful to have a way of making sure a message that you've sent is actually sent, as a GDBus-level feature.
Sure, we should probably add g_dbus_connection_flush{,_finish,_sync}() for this. It's a little involved implementing this: we need to poke the worker thread so it drains the work queue and flushes the underlying GIOStream (which itself has sync and async versions). > in some ways this could be consider a GSettings bug; in fact, i very nearly > added a g_settings_sync() API to wait until all outstanding writes had come > back, but i think it would be generally useful to have a way of making sure a > message that you've sent is actually sent, as a GDBus-level feature. I agree flush() is a feature and that you shouldn't need it in GSettings because flush() on GDBusConnection will only guarantee that the message is on the way to the peer (typically a message bus daemon instance), not that it gets any further. And the message may be blocked at several junctures on its journey to the destination. Presumably the code that you want to speak to using GDBus may reject the request by returning a D-Bus error or whatever, I don't know how GSettings work. That said, I'm not opposed to adding flush().
OK, added _flush{_finish,sync}(): http://git.gnome.org/browse/glib/commit/?id=62a1ccf526e7b23ac39cdf7251eac5706eef3f57