diff --git a/libfwupdplugin/fu-device.c b/libfwupdplugin/fu-device.c index 66620ae1b..39b2cb76d 100644 --- a/libfwupdplugin/fu-device.c +++ b/libfwupdplugin/fu-device.c @@ -56,9 +56,7 @@ typedef struct { FuContext *ctx; GHashTable *inhibits; /* (nullable) */ GHashTable *metadata; /* (nullable) */ - GRWLock metadata_mutex; GPtrArray *parent_guids; - GRWLock parent_guids_mutex; GPtrArray *parent_physical_ids; /* (nullable) */ guint remove_delay; /* ms */ guint acquiesce_delay; /* ms */ @@ -1459,10 +1457,7 @@ GPtrArray * fu_device_get_parent_guids(FuDevice *self) { FuDevicePrivate *priv = GET_PRIVATE(self); - g_autoptr(GRWLockReaderLocker) locker = - g_rw_lock_reader_locker_new(&priv->parent_guids_mutex); g_return_val_if_fail(FU_IS_DEVICE(self), NULL); - g_return_val_if_fail(locker != NULL, NULL); return priv->parent_guids; } @@ -1481,12 +1476,9 @@ gboolean fu_device_has_parent_guid(FuDevice *self, const gchar *guid) { FuDevicePrivate *priv = GET_PRIVATE(self); - g_autoptr(GRWLockReaderLocker) locker = - g_rw_lock_reader_locker_new(&priv->parent_guids_mutex); g_return_val_if_fail(FU_IS_DEVICE(self), FALSE); g_return_val_if_fail(guid != NULL, FALSE); - g_return_val_if_fail(locker != NULL, FALSE); for (guint i = 0; i < priv->parent_guids->len; i++) { const gchar *guid_tmp = g_ptr_array_index(priv->parent_guids, i); @@ -1516,7 +1508,6 @@ void fu_device_add_parent_guid(FuDevice *self, const gchar *guid) { FuDevicePrivate *priv = GET_PRIVATE(self); - g_autoptr(GRWLockWriterLocker) locker = NULL; g_return_if_fail(FU_IS_DEVICE(self)); g_return_if_fail(guid != NULL); @@ -1534,8 +1525,6 @@ fu_device_add_parent_guid(FuDevice *self, const gchar *guid) /* already valid */ if (fu_device_has_parent_guid(self, guid)) return; - locker = g_rw_lock_writer_locker_new(&priv->parent_guids_mutex); - g_return_if_fail(locker != NULL); g_ptr_array_add(priv->parent_guids, g_strdup(guid)); } @@ -2313,10 +2302,8 @@ const gchar * fu_device_get_metadata(FuDevice *self, const gchar *key) { FuDevicePrivate *priv = GET_PRIVATE(self); - g_autoptr(GRWLockReaderLocker) locker = g_rw_lock_reader_locker_new(&priv->metadata_mutex); g_return_val_if_fail(FU_IS_DEVICE(self), NULL); g_return_val_if_fail(key != NULL, NULL); - g_return_val_if_fail(locker != NULL, NULL); if (priv->metadata == NULL) return NULL; return g_hash_table_lookup(priv->metadata, key); @@ -2338,11 +2325,9 @@ fu_device_get_metadata_boolean(FuDevice *self, const gchar *key) { FuDevicePrivate *priv = GET_PRIVATE(self); const gchar *tmp; - g_autoptr(GRWLockReaderLocker) locker = g_rw_lock_reader_locker_new(&priv->metadata_mutex); g_return_val_if_fail(FU_IS_DEVICE(self), FALSE); g_return_val_if_fail(key != NULL, FALSE); - g_return_val_if_fail(locker != NULL, FALSE); if (priv->metadata == NULL) return FALSE; @@ -2370,11 +2355,9 @@ fu_device_get_metadata_integer(FuDevice *self, const gchar *key) const gchar *tmp; gchar *endptr = NULL; guint64 val; - g_autoptr(GRWLockReaderLocker) locker = g_rw_lock_reader_locker_new(&priv->metadata_mutex); g_return_val_if_fail(FU_IS_DEVICE(self), G_MAXUINT); g_return_val_if_fail(key != NULL, G_MAXUINT); - g_return_val_if_fail(locker != NULL, G_MAXUINT); if (priv->metadata == NULL) return G_MAXUINT; @@ -2402,10 +2385,8 @@ void fu_device_remove_metadata(FuDevice *self, const gchar *key) { FuDevicePrivate *priv = GET_PRIVATE(self); - g_autoptr(GRWLockWriterLocker) locker = g_rw_lock_writer_locker_new(&priv->metadata_mutex); g_return_if_fail(FU_IS_DEVICE(self)); g_return_if_fail(key != NULL); - g_return_if_fail(locker != NULL); if (priv->metadata == NULL) return; g_hash_table_remove(priv->metadata, key); @@ -2425,14 +2406,11 @@ void fu_device_set_metadata(FuDevice *self, const gchar *key, const gchar *value) { FuDevicePrivate *priv = GET_PRIVATE(self); - g_autoptr(GRWLockWriterLocker) locker = g_rw_lock_writer_locker_new(&priv->metadata_mutex); g_return_if_fail(FU_IS_DEVICE(self)); g_return_if_fail(key != NULL); g_return_if_fail(value != NULL); - g_return_if_fail(locker != NULL); - if (priv->metadata == NULL) { + if (priv->metadata == NULL) priv->metadata = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); - } g_hash_table_insert(priv->metadata, g_strdup(key), g_strdup(value)); } @@ -3830,9 +3808,6 @@ fu_device_add_string(FuDevice *self, guint idt, GString *str) FuDeviceClass *klass = FU_DEVICE_GET_CLASS(self); FuDevicePrivate *priv = GET_PRIVATE(self); g_autofree gchar *tmp = NULL; - g_autoptr(GRWLockReaderLocker) locker = g_rw_lock_reader_locker_new(&priv->metadata_mutex); - - g_return_if_fail(locker != NULL); tmp = fwupd_device_to_string(FWUPD_DEVICE(self)); if (tmp != NULL && tmp[0] != '\0') @@ -5091,17 +5066,14 @@ fu_device_incorporate(FuDevice *self, FuDevice *donor) fu_device_set_custom_flags(self, priv_donor->custom_flags); if (priv->ctx == NULL) fu_device_set_context(self, fu_device_get_context(donor)); - g_rw_lock_reader_lock(&priv_donor->parent_guids_mutex); for (guint i = 0; i < parent_guids->len; i++) fu_device_add_parent_guid(self, g_ptr_array_index(parent_guids, i)); - g_rw_lock_reader_unlock(&priv_donor->parent_guids_mutex); if (parent_physical_ids != NULL) { for (guint i = 0; i < parent_physical_ids->len; i++) { const gchar *tmp = g_ptr_array_index(parent_physical_ids, i); fu_device_add_parent_physical_id(self, tmp); } } - g_rw_lock_reader_lock(&priv_donor->metadata_mutex); if (priv->metadata != NULL) { g_hash_table_iter_init(&iter, priv_donor->metadata); while (g_hash_table_iter_next(&iter, &key, &value)) { @@ -5109,7 +5081,6 @@ fu_device_incorporate(FuDevice *self, FuDevice *donor) fu_device_set_metadata(self, key, value); } } - g_rw_lock_reader_unlock(&priv_donor->metadata_mutex); /* probably not required, but seems safer */ for (guint i = 0; i < priv_donor->possible_plugins->len; i++) { @@ -5778,8 +5749,6 @@ fu_device_init(FuDevice *self) priv->instance_hash = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); priv->backend_tags = g_ptr_array_new_with_free_func(g_free); priv->acquiesce_delay = 50; /* ms */ - g_rw_lock_init(&priv->parent_guids_mutex); - g_rw_lock_init(&priv->metadata_mutex); priv->notify_flags_handler_id = g_signal_connect(FWUPD_DEVICE(self), "notify::flags", G_CALLBACK(fu_device_flags_notify_cb), @@ -5792,9 +5761,6 @@ fu_device_finalize(GObject *object) FuDevice *self = FU_DEVICE(object); FuDevicePrivate *priv = GET_PRIVATE(self); - g_rw_lock_clear(&priv->metadata_mutex); - g_rw_lock_clear(&priv->parent_guids_mutex); - if (priv->alternate != NULL) g_object_unref(priv->alternate); if (priv->proxy != NULL) diff --git a/libfwupdplugin/fu-plugin.c b/libfwupdplugin/fu-plugin.c index 498ba4ff0..c77158d13 100644 --- a/libfwupdplugin/fu-plugin.c +++ b/libfwupdplugin/fu-plugin.c @@ -49,7 +49,6 @@ typedef struct { FuContext *ctx; GArray *device_gtypes; /* (nullable): of #GType */ GHashTable *cache; /* (nullable): platform_id:GObject */ - GRWLock cache_mutex; GHashTable *report_metadata; /* (nullable): key:value */ GFileMonitor *config_monitor; FuPluginData *data; @@ -163,10 +162,8 @@ gpointer fu_plugin_cache_lookup(FuPlugin *self, const gchar *id) { FuPluginPrivate *priv = GET_PRIVATE(self); - g_autoptr(GRWLockReaderLocker) locker = g_rw_lock_reader_locker_new(&priv->cache_mutex); g_return_val_if_fail(FU_IS_PLUGIN(self), NULL); g_return_val_if_fail(id != NULL, NULL); - g_return_val_if_fail(locker != NULL, NULL); if (priv->cache == NULL) return NULL; return g_hash_table_lookup(priv->cache, id); @@ -186,11 +183,9 @@ void fu_plugin_cache_add(FuPlugin *self, const gchar *id, gpointer dev) { FuPluginPrivate *priv = GET_PRIVATE(self); - g_autoptr(GRWLockWriterLocker) locker = g_rw_lock_writer_locker_new(&priv->cache_mutex); g_return_if_fail(FU_IS_PLUGIN(self)); g_return_if_fail(id != NULL); g_return_if_fail(G_IS_OBJECT(dev)); - g_return_if_fail(locker != NULL); if (priv->cache == NULL) { priv->cache = g_hash_table_new_full(g_str_hash, g_str_equal, @@ -213,10 +208,8 @@ void fu_plugin_cache_remove(FuPlugin *self, const gchar *id) { FuPluginPrivate *priv = GET_PRIVATE(self); - g_autoptr(GRWLockWriterLocker) locker = g_rw_lock_writer_locker_new(&priv->cache_mutex); g_return_if_fail(FU_IS_PLUGIN(self)); g_return_if_fail(id != NULL); - g_return_if_fail(locker != NULL); if (priv->cache == NULL) return; g_hash_table_remove(priv->cache, id); @@ -2804,8 +2797,6 @@ fu_plugin_class_init(FuPluginClass *klass) static void fu_plugin_init(FuPlugin *self) { - FuPluginPrivate *priv = GET_PRIVATE(self); - g_rw_lock_init(&priv->cache_mutex); } static void @@ -2815,8 +2806,6 @@ fu_plugin_finalize(GObject *object) FuPluginPrivate *priv = GET_PRIVATE(self); FuPluginVfuncs *vfuncs = fu_plugin_get_vfuncs(self); - g_rw_lock_clear(&priv->cache_mutex); - /* optional */ if (priv->done_init && vfuncs->finalize != NULL) { g_debug("finalize(%s)", fu_plugin_get_name(self));