[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdebase/workspace/ksysguard/ksysguardd/Linux
From: John Tapsell <john.tapsell () kdemail ! net>
Date: 2009-08-25 22:24:47
Message-ID: 1251239087.285901.15211.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 1015584 by johnflux:
Forwardport r801043 from 3.5 branch, it somehow got lost.
"While the internal buffer /proc/cpuinfo is read into is 32k is size, reading
these 32k in a single chunk is not possible: Only up to a page wort of
information is being returned in a single read (reading stops as soon as the
full block for a subsequent CPU wouldn't fit into the buffer space remaining in
the page anymore). The effect is that only 5 or 6 CPUs (depending on the exact
size info for one CPU has) get their frequency displayed (and the respective
sensor offered for selection) on x86/x86-64 (where the page size is 4k).
Consequently, multiple reads (until zero bytes are read) must be issued to
obtain all information."
M +18 -7 cpuinfo.c
--- trunk/KDE/kdebase/workspace/ksysguard/ksysguardd/Linux/cpuinfo.c #1015583:1015584
@@ -171,13 +171,24 @@
return -1;
}
- n = read( fd, CpuInfoBuf, CPUINFOBUFSIZE - 1 );
- if ( n == CPUINFOBUFSIZE - 1 || n <= 0 ) {
- log_error( "Internal buffer too small to read \'/proc/cpuinfo\'" );
- CpuInfoOK = 0;
-
- close( fd );
- return -1;
+ n = 0;
+ for(;;) {
+ ssize_t len = read( fd, CpuInfoBuf + n, CPUINFOBUFSIZE - 1 - n );
+ if( len < 0 ) {
+ print_error( "Failed to read file \'/proc/cpuinfo\'!\n" );
+ CpuInfoOK = -1;
+ close( fd );
+ return -1;
+ }
+ n += len;
+ if( len == 0 ) /* reading finished */
+ break;
+ if( n == CPUINFOBUFSIZE - 1 ) {
+ log_error( "Internal buffer too small to read \'/proc/cpuinfo\'" );
+ CpuInfoOK = 0;
+ close( fd );
+ return -1;
+ }
}
close( fd );
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic