]> git.ipfire.org Git - thirdparty/dbus.git/commit
DBusPendingCall: Only update ->completed under the connection lock
authorManish Narang <Manish.Narang@kpit.com>
Thu, 25 Jan 2018 11:39:44 +0000 (11:39 +0000)
committerSimon McVittie <smcv@collabora.com>
Tue, 6 Feb 2018 18:48:35 +0000 (18:48 +0000)
commitd3e03eb50eefa5a38d87f274c7de73f36468459c
tree68c352723ebe031c26a8c8dd363c33b660837d4d
parent30f8a38b3c8f8756744d6b65dd8207302a683acc
DBusPendingCall: Only update ->completed under the connection lock

If one thread is blocking on a pending call, and another thread is
dispatching the connection, then we need them to agree on the value
of the completed flag by protecting all accesses with a lock. Reads
for this member seem to have the connection lock already, so it's
sufficient to make sure that the only write also happens under the
connection lock.

We already set the completed flag before calling the callback, so it
seems OK to stretch it to meaning that some thread has merely *taken
responsibility for* calling the callback.

The completed flag shares a bitfield with timeout_added, but that
flag is protected by the connection lock already.

Based on suggestions from Simon McVittie on
<https://bugs.freedesktop.org/show_bug.cgi?id=102839>.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=102839
[smcv: Revert indentation changes; add commit message]
Reviewed-by: Simon McVittie <smcv@collabora.com>
dbus/dbus-connection.c
dbus/dbus-pending-call-internal.h
dbus/dbus-pending-call.c