mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2024-12-13 15:04:42 +00:00
MINOR: threads: Implement thread_cpus_enabled() for FreeBSD.
Use cpuset_getaffinity() to implement thread_cpus_enabled() on FreeBSD, so that we can know the number of CPUs available, and automatically launch as much threads if nbthread isn't specified.
This commit is contained in:
parent
526dc95eb9
commit
46453d3f7d
@ -19,6 +19,10 @@
|
||||
#include <sched.h>
|
||||
#endif
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#include <sys/cpuset.h>
|
||||
#endif
|
||||
|
||||
#include <common/cfgparse.h>
|
||||
#include <common/hathreads.h>
|
||||
#include <common/standard.h>
|
||||
@ -122,6 +126,11 @@ static int thread_cpus_enabled()
|
||||
|
||||
if (sched_getaffinity(0, sizeof(mask), &mask) == 0)
|
||||
ret = CPU_COUNT(&mask);
|
||||
#elif defined(__FreeBSD__) && defined(USE_CPU_AFFINITY)
|
||||
cpuset_t cpuset;
|
||||
if (cpuset_getaffinity(CPU_LEVEL_CPUSET, CPU_WHICH_PID, -1,
|
||||
sizeof(cpuset), &cpuset) == 0)
|
||||
ret = CPU_COUNT(&cpuset);
|
||||
#endif
|
||||
#endif
|
||||
ret = MAX(ret, 1);
|
||||
|
Loading…
Reference in New Issue
Block a user