UDisks dbus async calls don't work sometimes when a second mainloop exists

PCMan pcman.tw at gmail.com
Tue Jun 29 12:59:16 PDT 2010


Hi list,
I'm not sure if this is a problem of UDisks or a dbus one, so I'm
asking about this on both mailing list.
When I tried to do auto-mouting devices, I found an issue about async
calls in UDisks. I write a simple test case to demostrate the problem.
It's included in the attachment of this mail.

I tried to connect to "DeviceAdded" signal of UDisks, and tried to
mount the newly added device in its signal handler by making an
asynchronous call to "FilesystemMount".
Then, for some reason, I hope that the call can be blocking, but
without blocking of GUI. So I run a second mainloop in the "DeviceAdd"
signal handler. So while the async call to FilesystemMount is still in
progress, my second mainloop can keep pumping signals for my GUI. This
nested mainloop tachnique is also used by GtkDialog in gtk_dialog_run,
so it should work.
Unfortunately, I found that when a second mainloop exists, the
callback of the async FilesystemMount call never gets called.
If I remove the nested mainloop, then the callback of async call works again.
Since both of my mainloop and dbus-glib uses the default GMainContext,
why this happens?

Is this a limitation, a bug, or I did something wrong?
Is there anyway to overcome or workaround this issue?

Thank you all
-------------- next part --------------
#!/bin/sh
gcc -o udisks-test `pkg-config gtk+-2.0 --cflags --libs` `pkg-config dbus-glib-1 --cflags --libs` *.c
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.c
Type: application/octet-stream
Size: 2204 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/dbus/attachments/20100630/f97bedd5/attachment-0003.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: udisks.h
Type: application/octet-stream
Size: 38136 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/dbus/attachments/20100630/f97bedd5/attachment-0004.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: udisks-device.h
Type: application/octet-stream
Size: 47431 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/dbus/attachments/20100630/f97bedd5/attachment-0005.obj>


More information about the dbus mailing list