X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=vswitchd%2Fsystem-stats.c;h=1d9cb78edff40d8b2c0affdbe1f4e9c538f3ba7f;hb=db19b72b9f6d0d40b743214241d9666116e3b448;hp=9e3d228ad879ae55665da60c6d5258bf8ca43606;hpb=d017eeb9f9ebcb46c24a67fd301b3e36cd26a04e;p=sliver-openvswitch.git diff --git a/vswitchd/system-stats.c b/vswitchd/system-stats.c index 9e3d228ad..1d9cb78ed 100644 --- a/vswitchd/system-stats.c +++ b/vswitchd/system-stats.c @@ -59,7 +59,7 @@ VLOG_DEFINE_THIS_MODULE(system_stats); static void get_cpu_cores(struct smap *stats) { - long int n_cores = sysconf(_SC_NPROCESSORS_ONLN); + long int n_cores = count_cpu_cores(); if (n_cores > 0) { smap_add_format(stats, "cpu", "%ld", n_cores); } @@ -148,7 +148,7 @@ get_memory_stats(struct smap *stats) char key[16]; int value; - if (sscanf(line, "%15[^:]: %u", key, &value) == 2) { + if (ovs_scan(line, "%15[^:]: %u", key, &value)) { int *valuep = shash_find_data(&dict, key); if (valuep) { *valuep = value; @@ -192,7 +192,7 @@ get_boot_time(void) while (fgets(line, sizeof line, stream)) { long long int btime; - if (sscanf(line, "btime %lld", &btime) == 1) { + if (ovs_scan(line, "btime %lld", &btime)) { boot_time = btime * 1000; goto done; } @@ -344,7 +344,7 @@ count_crashes(pid_t pid) paren = strchr(line, '('); if (paren) { int x; - if (sscanf(paren + 1, "%d", &x) == 1) { + if (ovs_scan(paren + 1, "%d", &x)) { crashes = x; } } @@ -506,7 +506,7 @@ get_filesys_stats(struct smap *stats OVS_UNUSED) #define SYSTEM_STATS_INTERVAL (5 * 1000) /* In milliseconds. */ -static struct ovs_mutex mutex = OVS_ADAPTIVE_MUTEX_INITIALIZER; +static struct ovs_mutex mutex = OVS_MUTEX_INITIALIZER; static pthread_cond_t cond = PTHREAD_COND_INITIALIZER; static struct latch latch OVS_GUARDED_BY(mutex); static bool enabled; @@ -576,7 +576,7 @@ system_stats_wait(void) } static void -discard_stats(void) OVS_REQUIRES(&mutex) +discard_stats(void) OVS_REQUIRES(mutex) { if (system_stats) { smap_destroy(system_stats);