mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-25 15:06:14 +01:00
gdbus: Fix atomic accesses to global name watch ID
https://bugzilla.gnome.org/show_bug.cgi?id=777307
This commit is contained in:
parent
b1f14143e5
commit
c131865f57
@ -77,7 +77,10 @@ typedef struct
|
||||
gboolean initialized;
|
||||
} Client;
|
||||
|
||||
static guint next_global_id = 1;
|
||||
/* Must be accessed atomically. */
|
||||
static volatile guint next_global_id = 1;
|
||||
|
||||
/* Must be accessed with @lock held. */
|
||||
static GHashTable *map_id_to_client = NULL;
|
||||
|
||||
static Client *
|
||||
@ -562,7 +565,7 @@ g_bus_watch_name (GBusType bus_type,
|
||||
|
||||
client = g_new0 (Client, 1);
|
||||
client->ref_count = 1;
|
||||
client->id = next_global_id++; /* TODO: uh oh, handle overflow */
|
||||
client->id = g_atomic_int_add (&next_global_id, 1); /* TODO: uh oh, handle overflow */
|
||||
client->name = g_strdup (name);
|
||||
client->flags = flags;
|
||||
client->name_appeared_handler = name_appeared_handler;
|
||||
@ -624,7 +627,7 @@ guint g_bus_watch_name_on_connection (GDBusConnection *connection,
|
||||
|
||||
client = g_new0 (Client, 1);
|
||||
client->ref_count = 1;
|
||||
client->id = next_global_id++; /* TODO: uh oh, handle overflow */
|
||||
client->id = g_atomic_int_add (&next_global_id, 1); /* TODO: uh oh, handle overflow */
|
||||
client->name = g_strdup (name);
|
||||
client->flags = flags;
|
||||
client->name_appeared_handler = name_appeared_handler;
|
||||
|
Loading…
Reference in New Issue
Block a user