mirror of
https://github.com/ZoiteChat/zoitechat.git
synced 2026-12-05 06:22:18 +00:00
fix release+refresh hardware caches
This commit is contained in:
6 files changed
+82
-30
No files matched your search
@@ -175,6 +175,12 @@ char *sysinfo_backend_get_uptime(void)
|
||||
return sysinfo_format_uptime (uptime);
|
||||
}
|
||||
|
||||
/* The legacy Unix backend does not cache hardware snapshots. */
|
||||
void
|
||||
sysinfo_backend_reset_cache (void)
|
||||
{
|
||||
}
|
||||
|
||||
char *sysinfo_backend_get_network(void)
|
||||
{
|
||||
char ethernet_card[bsize];
|
||||
|
||||
@@ -40,11 +40,27 @@ typedef struct
|
||||
GHashTable *pci_names;
|
||||
} LinuxStaticSnapshot;
|
||||
|
||||
/* Sysinfo callbacks and plugin teardown run on the client thread. */
|
||||
static LinuxStaticSnapshot snapshot;
|
||||
static gsize os_initialized = 0;
|
||||
static gsize cpu_initialized = 0;
|
||||
static gsize pci_initialized = 0;
|
||||
static gsize sound_initialized = 0;
|
||||
static gboolean os_initialized;
|
||||
static gboolean cpu_initialized;
|
||||
static gboolean pci_initialized;
|
||||
static gboolean sound_initialized;
|
||||
|
||||
void
|
||||
sysinfo_backend_reset_cache (void)
|
||||
{
|
||||
g_clear_pointer (&snapshot.os, g_free);
|
||||
g_clear_pointer (&snapshot.cpu, g_free);
|
||||
g_clear_pointer (&snapshot.gpu, g_free);
|
||||
g_clear_pointer (&snapshot.chipset, g_free);
|
||||
g_clear_pointer (&snapshot.sound, g_free);
|
||||
g_clear_pointer (&snapshot.pci_names, g_hash_table_unref);
|
||||
os_initialized = FALSE;
|
||||
cpu_initialized = FALSE;
|
||||
pci_initialized = FALSE;
|
||||
sound_initialized = FALSE;
|
||||
}
|
||||
|
||||
static char *read_trimmed_file (const char *path);
|
||||
static gboolean read_hex_file (const char *path, guint *value);
|
||||
@@ -642,40 +658,40 @@ build_os_string (void)
|
||||
static void
|
||||
ensure_os_snapshot (void)
|
||||
{
|
||||
if (g_once_init_enter (&os_initialized))
|
||||
if (!os_initialized)
|
||||
{
|
||||
snapshot.os = build_os_string ();
|
||||
g_once_init_leave (&os_initialized, 1);
|
||||
os_initialized = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
ensure_cpu_snapshot (void)
|
||||
{
|
||||
if (g_once_init_enter (&cpu_initialized))
|
||||
if (!cpu_initialized)
|
||||
{
|
||||
snapshot.cpu = build_cpu_string ();
|
||||
g_once_init_leave (&cpu_initialized, 1);
|
||||
cpu_initialized = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
ensure_pci_snapshot (void)
|
||||
{
|
||||
if (g_once_init_enter (&pci_initialized))
|
||||
if (!pci_initialized)
|
||||
{
|
||||
scan_pci_devices ();
|
||||
g_once_init_leave (&pci_initialized, 1);
|
||||
pci_initialized = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
ensure_sound_snapshot (void)
|
||||
{
|
||||
if (g_once_init_enter (&sound_initialized))
|
||||
if (!sound_initialized)
|
||||
{
|
||||
snapshot.sound = build_sound_string ();
|
||||
g_once_init_leave (&sound_initialized, 1);
|
||||
sound_initialized = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user