trivial: Rename the device cache store with a better name

This commit is contained in:
Richard Hughes 2021-01-13 14:00:20 +00:00
parent 1a3d3b338e
commit faf2afed02

View File

@ -48,8 +48,8 @@ typedef struct {
GPtrArray *udev_subsystems;
FuSmbios *smbios;
GType device_gtype;
GHashTable *devices; /* (nullable): platform_id:GObject */
GRWLock devices_mutex;
GHashTable *cache; /* (nullable): platform_id:GObject */
GRWLock cache_mutex;
GHashTable *report_metadata; /* (nullable): key:value */
FuPluginData *data;
} FuPluginPrivate;
@ -209,13 +209,13 @@ 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->devices_mutex);
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->devices == NULL)
if (priv->cache == NULL)
return NULL;
return g_hash_table_lookup (priv->devices, id);
return g_hash_table_lookup (priv->cache, id);
}
/**
@ -232,17 +232,17 @@ 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->devices_mutex);
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->devices == NULL) {
priv->devices = g_hash_table_new_full (g_str_hash,
g_str_equal,
g_free,
(GDestroyNotify) g_object_unref);
if (priv->cache == NULL) {
priv->cache = g_hash_table_new_full (g_str_hash,
g_str_equal,
g_free,
(GDestroyNotify) g_object_unref);
}
g_hash_table_insert (priv->devices, g_strdup (id), g_object_ref (dev));
g_hash_table_insert (priv->cache, g_strdup (id), g_object_ref (dev));
}
/**
@ -258,13 +258,13 @@ 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->devices_mutex);
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->devices == NULL)
if (priv->cache == NULL)
return;
g_hash_table_remove (priv->devices, id);
g_hash_table_remove (priv->cache, id);
}
/**
@ -2881,7 +2881,7 @@ static void
fu_plugin_init (FuPlugin *self)
{
FuPluginPrivate *priv = GET_PRIVATE (self);
g_rw_lock_init (&priv->devices_mutex);
g_rw_lock_init (&priv->cache_mutex);
}
static void
@ -2891,7 +2891,7 @@ fu_plugin_finalize (GObject *object)
FuPluginPrivate *priv = GET_PRIVATE (self);
FuPluginInitFunc func = NULL;
g_rw_lock_clear (&priv->devices_mutex);
g_rw_lock_clear (&priv->cache_mutex);
/* optional */
if (priv->module != NULL) {
@ -2922,8 +2922,8 @@ fu_plugin_finalize (GObject *object)
g_hash_table_unref (priv->compile_versions);
if (priv->report_metadata != NULL)
g_hash_table_unref (priv->report_metadata);
if (priv->devices != NULL)
g_hash_table_unref (priv->devices);
if (priv->cache != NULL)
g_hash_table_unref (priv->cache);
g_free (priv->build_hash);
g_free (priv->data);
/* Must happen as the last step to avoid prematurely