mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-09-07 08:28:43 +02:00
GDBusConnection: check for initialization where needed for thread-safety
Also document which fields require such a check in order to have correct threading semantics. This usage doesn't matches the GInitable documentation, which suggests use of a GError - but using an uninitialized GDBusConnection is programming error, and not usefully recoverable. (The GInitable documentation may have been a mistake - GNOME#662208.) Also, not all of the places where we need it can raise a GError. The check serves a dual purpose: it turns a non-deterministic crash into a deterministic critical warning, and is also a memory barrier for thread-safety. All of these functions dereference or return fields that are meant to be protected by FLAG_INITIALIZED, so they could crash or return an undefined value to their caller without this, if called from a thread that isn't the one that called initable_init() (although I can't think of any way to do that without encountering a memory barrier, undefined behaviour, or a race condition that leads to undefined behaviour if the non-initializing thread wins the race). One exception is that initable_init() itself makes a synchronous call. We deal with that by passing new internal flags up the call stack, to reassure g_dbus_connection_send_message_unlocked() that it can go ahead. Bug: https://bugzilla.gnome.org/show_bug.cgi?id=661689 Bug: https://bugzilla.gnome.org/show_bug.cgi?id=661992 Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk> Reviewed-by: David Zeuthen <davidz@redhat.com>
This commit is contained in:
@@ -1053,6 +1053,7 @@ typedef enum {
|
||||
G_DBUS_CALL_FLAGS_NONE = 0,
|
||||
G_DBUS_CALL_FLAGS_NO_AUTO_START = (1<<0)
|
||||
} GDBusCallFlags;
|
||||
/* (1<<31) is reserved for internal use by GDBusConnection, do not use it. */
|
||||
|
||||
/**
|
||||
* GDBusMessageType:
|
||||
@@ -1208,6 +1209,7 @@ typedef enum
|
||||
G_DBUS_SEND_MESSAGE_FLAGS_NONE = 0,
|
||||
G_DBUS_SEND_MESSAGE_FLAGS_PRESERVE_SERIAL = (1<<0)
|
||||
} GDBusSendMessageFlags;
|
||||
/* (1<<31) is reserved for internal use by GDBusConnection, do not use it. */
|
||||
|
||||
/**
|
||||
* GCredentialsType:
|
||||
|
Reference in New Issue
Block a user