Don't finalize sent or dispatched messages while under the connection lock
authorSimon McVittie <simon.mcvittie@collabora.co.uk>
Fri, 25 Feb 2011 17:46:54 +0000 (17:46 +0000)
committerSimon McVittie <simon.mcvittie@collabora.co.uk>
Thu, 28 Jul 2011 17:23:35 +0000 (18:23 +0100)
commit8304d4a06413bc4be6a1d282e5594bd545413082
tree6647334515a9ed4e50dd9d6c7f1078b332b9dd07
parentacf4056a42c77ee70c91c466a0e12b942fe74154
Don't finalize sent or dispatched messages while under the connection lock

Finalizing a message can trigger callbacks; that's bad, if we have a
connection locked.

In particular, if a message is received by the "left side", passed to
the "right side" and sent (as in test/relay.c (see the diagram there)
or in dbus-daemon), then finalizing that message could result in the
live messages counter for the left side, and the outgoing messages counter
for the right side, both being decremented while under either side's
lock.

After a message is dispatched on the left side, finalizing it now drops
the lock temporarily, to avoid this problem.

After a message is sent on the right side, finalizing it is now deferred
until the right side unlocks, by moving it to a new queue of
"expired messages" which is automatically cleared every time we release
the lock.

The "live messages" counter for the "left" connection will now explicitly
take the left connection's lock before decrementing, to avoid
manipulating watches without a lock.

Reviewed-by: Colin Walters <walters@verbum.org>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=34393
dbus/dbus-connection.c
dbus/dbus-transport.c