diff --git a/dbus/dbus-connection.c b/dbus/dbus-connection.c index 81b3a83..a3559d2 100644 --- a/dbus/dbus-connection.c +++ b/dbus/dbus-connection.c @@ -2325,10 +2325,11 @@ complete_pending_call_and_unlock (DBusConnection *connection, { _dbus_pending_call_set_reply_unlocked (pending, message); _dbus_pending_call_ref_unlocked (pending); /* in case there's no app with a ref held */ + _dbus_pending_call_start_completion_unlocked(pending); _dbus_connection_detach_pending_call_and_unlock (connection, pending); - + /* Must be called unlocked since it invokes app callback */ - _dbus_pending_call_complete (pending); + _dbus_pending_call_finish_completion (pending); dbus_pending_call_unref (pending); } @@ -2525,7 +2526,7 @@ _dbus_connection_block_pending_call (DBusPendingCall *pending) { /* block again, we don't have the reply buffered yet. */ _dbus_connection_do_iteration_unlocked (connection, - NULL, + pending, DBUS_ITERATION_DO_READING | DBUS_ITERATION_BLOCK, timeout_milliseconds - elapsed_milliseconds); diff --git a/dbus/dbus-pending-call-internal.h b/dbus/dbus-pending-call-internal.h index 393e660..cd8ab1a 100644 --- a/dbus/dbus-pending-call-internal.h +++ b/dbus/dbus-pending-call-internal.h @@ -41,7 +41,10 @@ void _dbus_pending_call_set_reply_serial_unlocked (DBusPendingCal DBusConnection * _dbus_pending_call_get_connection_and_lock (DBusPendingCall *pending); DBusConnection * _dbus_pending_call_get_connection_unlocked (DBusPendingCall *pending); dbus_bool_t _dbus_pending_call_get_completed_unlocked (DBusPendingCall *pending); -void _dbus_pending_call_complete (DBusPendingCall *pending); + +void _dbus_pending_call_start_completion_unlocked (DBusPendingCall *pending); +void _dbus_pending_call_finish_completion (DBusPendingCall *pending); + void _dbus_pending_call_set_reply_unlocked (DBusPendingCall *pending, DBusMessage *message); void _dbus_pending_call_queue_timeout_error_unlocked (DBusPendingCall *pending, diff --git a/dbus/dbus-pending-call.c b/dbus/dbus-pending-call.c index be53410..2e883c9 100644 --- a/dbus/dbus-pending-call.c +++ b/dbus/dbus-pending-call.c @@ -194,27 +194,38 @@ _dbus_pending_call_set_reply_unlocked (DBusPendingCall *pending, } /** + * Sets the pending call to completed + * + * Called with the connection lock held, to protect pending->completed + * + * @param pending the pending call + */ +void +_dbus_pending_call_start_completion_unlocked (DBusPendingCall *pending) +{ + _dbus_assert (!pending->completed); + + pending->completed = TRUE; +} + +/** * Calls notifier function for the pending call - * and sets the call to completed. * * @param pending the pending call - * */ void -_dbus_pending_call_complete (DBusPendingCall *pending) +_dbus_pending_call_finish_completion (DBusPendingCall *pending) { - _dbus_assert (!pending->completed); - - pending->completed = TRUE; + _dbus_assert (pending->completed); if (pending->function) - { - void *user_data; - user_data = dbus_pending_call_get_data (pending, - notify_user_data_slot); - - (* pending->function) (pending, user_data); - } + { + void *user_data; + user_data = dbus_pending_call_get_data (pending, + notify_user_data_slot); + + (* pending->function) (pending, user_data); + } } /**