ovs-thread: Fix crash by making count_cpu_count() return type a signed int.
authorBen Pfaff <blp@nicira.com>
Fri, 13 Dec 2013 22:31:27 +0000 (14:31 -0800)
committerBen Pfaff <blp@nicira.com>
Fri, 13 Dec 2013 23:06:37 +0000 (15:06 -0800)
commit4974b2b8119e8268eb7cababf82f2e7d84455f4a
treee3bcb0ba612a2e9c8c930a9a5e4bf061d90ac17e
parent2b4cca6fc24ece6c727f877a9f17dd5f32da7f84
ovs-thread: Fix crash by making count_cpu_count() return type a signed int.

ofproto_set_threads() uses the calculation MAX(count_cpu_cores() - 2, 1)
to decide on the default thread count.  However, count_cpu_cores() returns
0 if it can't count the number of cores, or 1 if there's only one core,
and that causes the calculation to come out as UINT_MAX-2 or UINT_MAX-1,
respectively, which causes a memory allocation failure later.

There are other ways to fix this problem, too, of course.

Signed-off-by: Ben Pfaff <blp@nicira.com>
lib/ovs-thread.c
lib/ovs-thread.h