_SC_NPROCESSORS_ONLN -> _SC_NPROCESSORS_CONF
authorPierre-Marc Fournier <pierre-marc.fournier@polymtl.ca>
Tue, 2 Feb 2010 02:43:03 +0000 (21:43 -0500)
committerPierre-Marc Fournier <pierre-marc.fournier@polymtl.ca>
Tue, 2 Feb 2010 02:43:03 +0000 (21:43 -0500)
libust/buffers.c

index 13660a8910402ad45e163c524aa845d37025a6df..7d2dd47336ecfda237a6d6564b99f2bca38f3000 100644 (file)
@@ -45,7 +45,15 @@ static int get_n_cpus(void)
                return n_cpus;
        }
 
-       result = sysconf(_SC_NPROCESSORS_ONLN);
+       /* On Linux, when some processors are offline
+        * _SC_NPROCESSORS_CONF counts the offline
+        * processors, whereas _SC_NPROCESSORS_ONLN
+        * does not. If we used _SC_NPROCESSORS_ONLN,
+        * getcpu() could return a value greater than
+        * this sysconf, in which case the arrays
+        * indexed by processor would overflow.
+        */
+       result = sysconf(_SC_NPROCESSORS_CONF);
        if(result == -1) {
                return -1;
        }
This page took 0.024689 seconds and 4 git commands to generate.