summaryrefslogtreecommitdiffstats
path: root/libc
diff options
context:
space:
mode:
authorMikael Ohlson <mikael.ohlson@stericsson.com>2010-05-21 11:20:39 +0200
committerChristian Bejram <christian.bejram@stericsson.com>2010-06-16 22:02:20 +0000
commitb44fcd6e8f661e7e795212a3b68aa171ab6e49c9 (patch)
tree958e899894cc2cce7cef9a0e3590b6ab76192325 /libc
parent16c91eff09e13ab62cea4ef5044518264483faeb (diff)
downloadbionic-b44fcd6e8f661e7e795212a3b68aa171ab6e49c9.zip
bionic-b44fcd6e8f661e7e795212a3b68aa171ab6e49c9.tar.gz
bionic-b44fcd6e8f661e7e795212a3b68aa171ab6e49c9.tar.bz2
Fix for incorrect reply from sysconf(_SC_NPROCESSORS_ONLN)
When calling sysconf with _SC_NPROCESSORS_ONLN, the value one (1) was returned on systems with two or more cores, since '/proc/stat' was incorrectly parsed. The function line_parser_getc (LineParser* p) read 128 characters of input for each invocation. The proper and probably aimed for behavior is to read 128 characters at the first call, then for each subsequent call only return the next buffered character until a new read is needed and only then read another 128 characters. Due to a flipped comparison between the two variables in_len and in_pos that track the number of bytes of data read into the input buffer and how much of it has been parsed, a new group of 128 characters were read at almost every call to line_parser_getc, overwriting the still unhandled bytes from the previous call to read. This caused the lines to be read to be sampled more than parsed. Change-Id: I93eec3c8c9b9f19ef798748579d0977111b5c0bb Signed-off-by: Christian Bejram <christian.bejram@stericsson.com>
Diffstat (limited to 'libc')
-rw-r--r--libc/unistd/sysconf.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/libc/unistd/sysconf.c b/libc/unistd/sysconf.c
index d3089a4..dedc5bc 100644
--- a/libc/unistd/sysconf.c
+++ b/libc/unistd/sysconf.c
@@ -317,7 +317,7 @@ line_parser_addc( LineParser* p, int c )
static int
line_parser_getc( LineParser* p )
{
- if (p->in_len >= p->in_pos) {
+ if (p->in_pos >= p->in_len) {
int ret;
p->in_len = p->in_pos = 0;