[PATCH] Privatize the DBusPendingCall struct

Thiago Macieira thiago at kde.org
Thu Jul 20 09:31:27 PDT 2006


John (J5) Palmieri wrote:
>Take 2. I'm going to go ahead and look into keeping a ref for the
>connection.  If the patch is approved I will commit it.

Taking a ref makes the connection be locked:

DBusConnection *
dbus_connection_ref (DBusConnection *connection)
{
[...]
#ifdef DBUS_HAVE_ATOMIC_INT
  _dbus_atomic_inc (&connection->refcount);
#else
  CONNECTION_LOCK (connection);
  _dbus_assert (connection->refcount.value > 0);

  connection->refcount.value += 1;
  CONNECTION_UNLOCK (connection);
#endif
[...]
}

Since this is called from dbus_connection_send_with_reply (indirectly, 
through _dbus_pending_call_new), the connection is locked twice and the 
program, thus, deadlocks.

Are mutexes now required to be recursive?

This was the backtrace that led me to the problem:
#0  0x00002ac41306b7f6 in pthread_cond_wait@@GLIBC_2.3.2 ()
   from /lib64/libpthread.so.0
#1  0x00002ac412dde969 in QMutexPrivate::wait (this=0x5a9a80)
    at thread/qmutex_unix.cpp:59
#2  0x00002ac412ddb51a in QMutex::lock (this=0x5aa680)
    at thread/qmutex.cpp:192
#3  0x00002ac413f3dce7 in DBusMutex::mutex_lock (mutex=0x5aa680)
    at qdbusthread.cpp:48
#4  0x00002ac4167c02d3 in dbus_connection_ref (connection=0x5aa880)
    at dbus-connection.c:1727
#5  0x00002ac4167cfd41 in _dbus_pending_call_new (connection=0x5aa880, 
    timeout_milliseconds=<value optimized out>, 
    timeout_handler=0x2ac4167c3ee0 <reply_handler_timeout>)
    at dbus-pending-call.c:122
#6  0x00002ac4167c3b56 in dbus_connection_send_with_reply (
    connection=0x5aa880, message=0x5a9f40, pending_return=0x7fff99488230, 
    timeout_milliseconds=-1) at dbus-connection.c:2396
#7  0x00002ac4167c3dd5 in dbus_connection_send_with_reply_and_block (
    connection=0x5aa880, message=0x5a9f40, timeout_milliseconds=-1, 
    error=0x5a9648) at dbus-connection.c:2772
#8  0x00002ac4167bf91f in dbus_bus_register (connection=0x5a9ac4, 
    error=0x5a9648) at dbus-bus.c:510
#9  0x00002ac4167bfc74 in internal_bus_get (type=DBUS_BUS_SESSION, 
    error=0x5a9648, private=1) at dbus-bus.c:394

-- 
  Thiago Macieira  -  thiago (AT) macieira.info - thiago (AT) kde.org
    PGP/GPG: 0x6EF45358; fingerprint:
    E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/dbus/attachments/20060720/cf60ec64/attachment.pgp


More information about the dbus mailing list