#include "hud/hud_private.h"
#include "util/list.h"
#include "os/os_time.h"
+#include "os/os_thread.h"
#include "util/u_memory.h"
#include <stdio.h>
#include <unistd.h>
static int gcpufreq_count = 0;
static struct list_head gcpufreq_list;
+pipe_static_mutex(gcpufreq_mutex);
static struct cpufreq_info *
find_cfi_by_index(int cpu_index, int mode)
int cpu_index;
/* Return the number of CPU metrics we support. */
- if (gcpufreq_count)
+ pipe_mutex_lock(gcpufreq_mutex);
+ if (gcpufreq_count) {
+ pipe_mutex_unlock(gcpufreq_mutex);
return gcpufreq_count;
+ }
/* Scan /sys/devices.../cpu, for every object type we support, create
* and persist an object to represent its different metrics.
*/
list_inithead(&gcpufreq_list);
DIR *dir = opendir("/sys/devices/system/cpu");
- if (!dir)
+ if (!dir) {
+ pipe_mutex_unlock(gcpufreq_mutex);
return 0;
+ }
while ((dp = readdir(dir)) != NULL) {
}
}
+ pipe_mutex_unlock(gcpufreq_mutex);
return gcpufreq_count;
}
#include "hud/hud_private.h"
#include "util/list.h"
#include "os/os_time.h"
+#include "os/os_thread.h"
#include "util/u_memory.h"
#include <stdio.h>
#include <unistd.h>
*/
static int gdiskstat_count = 0;
static struct list_head gdiskstat_list;
+pipe_static_mutex(gdiskstat_mutex);
static struct diskstat_info *
find_dsi_by_name(const char *n, int mode)
char name[64];
/* Return the number of block devices and partitions. */
- if (gdiskstat_count)
+ pipe_mutex_lock(gdiskstat_mutex);
+ if (gdiskstat_count) {
+ pipe_mutex_unlock(gdiskstat_mutex);
return gdiskstat_count;
+ }
/* Scan /sys/block, for every object type we support, create and
* persist an object to represent its different statistics.
*/
list_inithead(&gdiskstat_list);
DIR *dir = opendir("/sys/block/");
- if (!dir)
+ if (!dir) {
+ pipe_mutex_unlock(gdiskstat_mutex);
return 0;
+ }
while ((dp = readdir(dir)) != NULL) {
struct dirent *dpart;
DIR *pdir = opendir(basename);
if (!pdir) {
+ pipe_mutex_unlock(gdiskstat_mutex);
closedir(dir);
return 0;
}
puts(line);
}
}
+ pipe_mutex_unlock(gdiskstat_mutex);
return gdiskstat_count;
}
#include "hud/hud_private.h"
#include "util/list.h"
#include "os/os_time.h"
+#include "os/os_thread.h"
#include "util/u_memory.h"
#include <stdio.h>
#include <unistd.h>
*/
static int gnic_count = 0;
static struct list_head gnic_list;
+pipe_static_mutex(gnic_mutex);
static struct nic_info *
find_nic_by_name(const char *n, int mode)
char name[64];
/* Return the number if network interfaces. */
- if (gnic_count)
+ pipe_mutex_lock(gnic_mutex);
+ if (gnic_count) {
+ pipe_mutex_unlock(gnic_mutex);
return gnic_count;
+ }
/* Scan /sys/block, for every object type we support, create and
* persist an object to represent its different statistics.
*/
list_inithead(&gnic_list);
DIR *dir = opendir("/sys/class/net/");
- if (!dir)
+ if (!dir) {
+ pipe_mutex_unlock(gnic_mutex);
return 0;
+ }
while ((dp = readdir(dir)) != NULL) {
}
+ pipe_mutex_unlock(gnic_mutex);
return gnic_count;
}
#include "hud/hud_private.h"
#include "util/list.h"
#include "os/os_time.h"
+#include "os/os_thread.h"
#include "util/u_memory.h"
#include <stdio.h>
#include <unistd.h>
*/
static int gsensors_temp_count = 0;
static struct list_head gsensors_temp_list;
+pipe_static_mutex(gsensor_temp_mutex);
struct sensors_temp_info
{
hud_get_num_sensors(bool displayhelp)
{
/* Return the number of sensors detected. */
- if (gsensors_temp_count)
+ pipe_mutex_lock(gsensor_temp_mutex);
+ if (gsensors_temp_count) {
+ pipe_mutex_unlock(gsensor_temp_mutex);
return gsensors_temp_count;
+ }
int ret = sensors_init(NULL);
- if (ret)
+ if (ret) {
+ pipe_mutex_unlock(gsensor_temp_mutex);
return 0;
+ }
list_inithead(&gsensors_temp_list);
}
}
+ pipe_mutex_unlock(gsensor_temp_mutex);
return gsensors_temp_count;
}