linux: relax assumption on /proc/stat parsing
CPU entries in /proc/stat are not guaranteed to be monotonically increasing, asserting on this assumption can break in cases such as the UltraSparc II machine shown in #1080. Signed-off-by: Luca Bruno <lucab@debian.org>
This commit is contained in:
parent
97eda7fd62
commit
993151bc40
@ -601,9 +601,9 @@ static int read_times(unsigned int numcpus, uv_cpu_info_t* ci) {
|
||||
|
||||
/* skip "cpu<num> " marker */
|
||||
{
|
||||
unsigned int n = num;
|
||||
unsigned int n;
|
||||
assert(sscanf(buf, "cpu%u ", &n) == 1);
|
||||
for (len = sizeof("cpu0"); n /= 10; len++);
|
||||
assert(sscanf(buf, "cpu%u ", &n) == 1 && n == num);
|
||||
}
|
||||
|
||||
/* Line contains user, nice, system, idle, iowait, irq, softirq, steal,
|
||||
@ -630,6 +630,7 @@ static int read_times(unsigned int numcpus, uv_cpu_info_t* ci) {
|
||||
ci[num++].cpu_times = ts;
|
||||
}
|
||||
fclose(fp);
|
||||
assert(num == numcpus);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user