dbus and multithreading
Leonid Yurchenko
nocturne at qarea.com
Wed Jun 1 11:55:41 PDT 2011
Hi Pavel.
Yes, dbus_threads_init() is called, sorry for not mentioning that.
On 06/01/2011 07:46 PM, Pavel Strashkin wrote:
> Hi Leonid,
>
> Have you initialized thread support in your application/service before
> any dbus calls?
>
> ===BEG DOC===
> After calling dbus_threads_init(), DBusConnection has thread locks and
> drops them when invoking user callbacks, so in general is
> transparently threadsafe. However, DBusMessage does NOT have thread
> locks; you must not send the same message to multiple DBusConnection
> if those connections will be used from different threads, for example.
>
> Also, if you dispatch or pop messages from multiple threads, it may
> work in the sense that it won't crash, but it's tough to imagine sane
> results; it will be completely unpredictable which messages go to
> which threads.
>
> It's recommended to dispatch from a single thread.
>
> The most useful function to call from multiple threads at once is
> dbus_connection_send_with_reply_and_block(). That is, multiple threads
> can make method calls at the same time.
>
> If you aren't using threads, you can use a main loop and
> dbus_pending_call_set_notify() to achieve a similar result
> ===END DOC===
>
> 2011/6/1 Leonid Yurchenko<nocturne at qarea.com>:
>> Hi All.
>>
>> I'm getting problems when using dbus from a worker thread. Problem is pretty
>> the same as described in
>> http://lists.freedesktop.org/archives/dbus/2009-June/011554.html as 1-st
>> problem.
>>
>> Shortly, it's assertion failure in dbus_pending_call_block.
>>
>> Mentioned message seems to not have any reply. So question is open for me -
>> is dbus glib considered as thread safe? And will these issues be addressed
>> any time soon, or we are stuck with one-threaded (gmainloop) approach?
>>
>> Thanks,
>> Leonid.
>> _______________________________________________
>> dbus mailing list
>> dbus at lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/dbus
>>
More information about the dbus
mailing list