Updated code based on review of ac308dcb2c34e081f9814ad40c0961a217c86fc4

Removed unnecessary spinlock and added more checks.
This commit is contained in:
Markus Makela
2015-11-02 10:29:47 +02:00
parent 6810ed15dd
commit 529e697eaf
4 changed files with 19 additions and 17 deletions

View File

@ -235,8 +235,14 @@ struct hostent *hp;
long get_processor_count()
{
long processors = 1;
#ifdef _SC_NPROCESSORS_CONF
processors = sysconf(_SC_NPROCESSORS_CONF);
#ifdef _SC_NPROCESSORS_ONLN
if ((processors = sysconf(_SC_NPROCESSORS_ONLN)) <= 0)
{
skygw_log_write(LE, "Unable to establish the number of available cores. Defaulting to 4.");
processors = 4;
}
#else
#error _SC_NPROCESSORS_ONLN not available.
#endif
return processors;
}