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>
* Tries not to count hyper-threads, but may be inaccurate - particularly on
* platforms that do not provide /proc/cpuinfo, but also if /proc/cpuinfo is
* formatted different to the layout that parse_cpuinfo() expects. */
-unsigned int
+int
count_cpu_cores(void)
{
static struct ovsthread_once once = OVSTHREAD_ONCE_INITIALIZER;
\f
/* Useful functions related to threading. */
-unsigned int count_cpu_cores(void);
+int count_cpu_cores(void);
#endif /* ovs-thread.h */