Merge branch 'lock-debug-cleanup' into 'main'

Draft: Cleanup of debug messages for connection and server locks

Closes #438

See merge request dbus/dbus!385
This commit is contained in:
Ralf Habacker 2026-01-10 02:45:59 +00:00
commit 036fb63472
4 changed files with 174 additions and 176 deletions

File diff suppressed because it is too large Load diff

View file

@ -49,15 +49,6 @@
* Opaque object representing a reply message that we're waiting for.
*/
/**
* shorter and more visible way to write _dbus_connection_lock()
*/
#define CONNECTION_LOCK(connection) _dbus_connection_lock(connection)
/**
* shorter and more visible way to write _dbus_connection_unlock()
*/
#define CONNECTION_UNLOCK(connection) _dbus_connection_unlock(connection)
/**
* Implementation details of #DBusPendingCall - all fields are private.
*/
@ -353,7 +344,7 @@ _dbus_pending_call_get_connection_and_lock (DBusPendingCall *pending)
{
_dbus_assert (pending != NULL);
CONNECTION_LOCK (pending->connection);
_dbus_connection_lock (pending->connection);
return pending->connection;
}
@ -492,7 +483,7 @@ _dbus_pending_call_unref_and_unlock (DBusPendingCall *pending)
_dbus_pending_call_trace_ref (pending, old_refcount,
old_refcount - 1, "unref_and_unlock");
CONNECTION_UNLOCK (pending->connection);
_dbus_connection_unlock (pending->connection);
if (old_refcount == 1)
_dbus_pending_call_last_unref (pending);
@ -543,7 +534,7 @@ _dbus_pending_call_set_data_unlocked (DBusPendingCall *pending,
&old_free_func, &old_data);
/* Drop locks to call out to app code */
CONNECTION_UNLOCK (pending->connection);
_dbus_connection_unlock (pending->connection);
if (retval)
{
@ -551,7 +542,7 @@ _dbus_pending_call_set_data_unlocked (DBusPendingCall *pending,
(* old_free_func) (old_data);
}
CONNECTION_LOCK (pending->connection);
_dbus_connection_lock (pending->connection);
return retval;
}
@ -657,7 +648,7 @@ dbus_pending_call_set_notify (DBusPendingCall *pending,
_dbus_return_val_if_fail (pending != NULL, FALSE);
CONNECTION_LOCK (pending->connection);
_dbus_connection_lock (pending->connection);
/* could invoke application code! */
if (!_dbus_pending_call_set_data_unlocked (pending, notify_user_data_slot,
@ -668,7 +659,7 @@ dbus_pending_call_set_notify (DBusPendingCall *pending,
ret = TRUE;
out:
CONNECTION_UNLOCK (pending->connection);
_dbus_connection_unlock (pending->connection);
return ret;
}
@ -711,9 +702,9 @@ dbus_pending_call_get_completed (DBusPendingCall *pending)
_dbus_return_val_if_fail (pending != NULL, FALSE);
CONNECTION_LOCK (pending->connection);
_dbus_connection_lock (pending->connection);
completed = pending->completed;
CONNECTION_UNLOCK (pending->connection);
_dbus_connection_unlock (pending->connection);
return completed;
}
@ -736,12 +727,12 @@ dbus_pending_call_steal_reply (DBusPendingCall *pending)
_dbus_return_val_if_fail (pending->completed, NULL);
_dbus_return_val_if_fail (pending->reply != NULL, NULL);
CONNECTION_LOCK (pending->connection);
_dbus_connection_lock (pending->connection);
message = pending->reply;
pending->reply = NULL;
CONNECTION_UNLOCK (pending->connection);
_dbus_connection_unlock (pending->connection);
_dbus_message_trace_ref (message, -1, -1, "dbus_pending_call_steal_reply");
return message;
@ -838,9 +829,9 @@ dbus_pending_call_set_data (DBusPendingCall *pending,
_dbus_return_val_if_fail (slot >= 0, FALSE);
CONNECTION_LOCK (pending->connection);
_dbus_connection_lock (pending->connection);
retval = _dbus_pending_call_set_data_unlocked (pending, slot, data, free_data_func);
CONNECTION_UNLOCK (pending->connection);
_dbus_connection_unlock (pending->connection);
return retval;
}
@ -860,11 +851,11 @@ dbus_pending_call_get_data (DBusPendingCall *pending,
_dbus_return_val_if_fail (pending != NULL, NULL);
CONNECTION_LOCK (pending->connection);
_dbus_connection_lock (pending->connection);
res = _dbus_data_slot_list_get (&slot_allocator,
&pending->slot_list,
slot);
CONNECTION_UNLOCK (pending->connection);
_dbus_connection_unlock (pending->connection);
return res;
}

View file

@ -170,13 +170,13 @@ void _dbus_server_trace_ref (DBusServer *server,
#define TRACE_LOCKS 0
#define SERVER_LOCK(server) do { \
if (TRACE_LOCKS) { _dbus_verbose ("LOCK\n"); } \
if (TRACE_LOCKS) { _dbus_verbose ("LOCK server:%p mutex:%p\n", server, (server)->mutex); } \
_dbus_rmutex_lock ((server)->mutex); \
TOOK_LOCK_CHECK (server); \
} while (0)
#define SERVER_UNLOCK(server) do { \
if (TRACE_LOCKS) { _dbus_verbose ("UNLOCK\n"); } \
if (TRACE_LOCKS) { _dbus_verbose ("UNLOCK server:%p mutex:%p\n", server, (server)->mutex); } \
RELEASING_LOCK_CHECK (server); \
_dbus_rmutex_unlock ((server)->mutex); \
} while (0)

View file

@ -31,6 +31,12 @@
/* Protected by _dbus_threads_lock_platform_specific() */
static int thread_init_generation = 0;
#ifdef DBUS_DISABLE_CHECKS
#undef TRACE_LOCKS
#else
#define TRACE_LOCKS
#endif
/**
* @defgroup DBusThreadsInternals Thread functions
* @ingroup DBusInternals
@ -349,6 +355,9 @@ _dbus_lock (DBusGlobalLock lock)
!dbus_threads_init_default ())
return FALSE;
#ifdef TRACE_LOCKS
_dbus_verbose ("LOCK DBusGlobalLock:%d mutex:%p\n", lock, global_locks[lock]);
#endif
_dbus_platform_rmutex_lock (global_locks[lock]);
return TRUE;
}
@ -359,6 +368,9 @@ _dbus_unlock (DBusGlobalLock lock)
_dbus_assert (lock >= 0);
_dbus_assert (lock < _DBUS_N_GLOBAL_LOCKS);
#ifdef TRACE_LOCKS
_dbus_verbose ("UNLOCK DBusGlobalLock:%d mutex:%p\n", lock, global_locks[lock]);
#endif
_dbus_platform_rmutex_unlock (global_locks[lock]);
}