diff --git a/SOURCES/kde-workspace-ksysguard-grow-buffer-size-as-needed.patch b/SOURCES/kde-workspace-ksysguard-grow-buffer-size-as-needed.patch new file mode 100644 index 0000000..90fee37 --- /dev/null +++ b/SOURCES/kde-workspace-ksysguard-grow-buffer-size-as-needed.patch @@ -0,0 +1,50 @@ +diff --git a/ksysguard/ksysguardd/Linux/cpuinfo.c b/ksysguard/ksysguardd/Linux/cpuinfo.c +index 9427ec0..6e37b68 100644 +--- a/ksysguard/ksysguardd/Linux/cpuinfo.c ++++ b/ksysguard/ksysguardd/Linux/cpuinfo.c +@@ -40,8 +40,9 @@ static int numCores = 0; /* Total # of cores */ + static int HighNumCores = 0; /* Highest # of cores ever seen */ + static float* Clocks = 0; /* Array with one entry per core */ + +-#define CPUINFOBUFSIZE (32 * 1024) +-static char CpuInfoBuf[ CPUINFOBUFSIZE ]; ++/* Enough for 4-6 virtual cores. Larger values will be tried as needed. */ ++static size_t CpuInfoBufSize = 8 * 1024; ++static char* CpuInfoBuf = NULL; + static int Dirty = 0; + static struct SensorModul *CpuInfoSM; + +@@ -171,9 +172,12 @@ int updateCpuInfo( void ) + return -1; + } + ++ if ( CpuInfoBuf == NULL ) { ++ CpuInfoBuf = malloc( CpuInfoBufSize ); ++ } + n = 0; + for(;;) { +- ssize_t len = read( fd, CpuInfoBuf + n, CPUINFOBUFSIZE - 1 - n ); ++ ssize_t len = read( fd, CpuInfoBuf + n, CpuInfoBufSize - 1 - n ); + if( len < 0 ) { + print_error( "Failed to read file \'/proc/cpuinfo\'!\n" ); + CpuInfoOK = -1; +@@ -183,11 +187,14 @@ int updateCpuInfo( void ) + 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; ++ if( n == CpuInfoBufSize - 1 ) { ++ /* The buffer was too small. Double its size and keep going. */ ++ size_t new_size = CpuInfoBufSize * 2; ++ char* new_buffer = malloc( new_size ); ++ memcpy( new_buffer, CpuInfoBuf, n ); /* copy read data */ ++ free( CpuInfoBuf ); /* free old buffer */ ++ CpuInfoBuf = new_buffer; /* remember new buffer and size */ ++ CpuInfoBufSize = new_size; + } + } + diff --git a/SOURCES/kde-workspace-ksysguard-increase-cpu-buffer.patch b/SOURCES/kde-workspace-ksysguard-increase-cpu-buffer.patch deleted file mode 100644 index 553853c..0000000 --- a/SOURCES/kde-workspace-ksysguard-increase-cpu-buffer.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/ksysguard/ksysguardd/Linux/cpuinfo.c b/ksysguard/ksysguardd/Linux/cpuinfo.c -index 9427ec0..12786c5 100644 ---- a/ksysguard/ksysguardd/Linux/cpuinfo.c -+++ b/ksysguard/ksysguardd/Linux/cpuinfo.c -@@ -40,7 +40,7 @@ static int numCores = 0; /* Total # of cores */ - static int HighNumCores = 0; /* Highest # of cores ever seen */ - static float* Clocks = 0; /* Array with one entry per core */ - --#define CPUINFOBUFSIZE (32 * 1024) -+#define CPUINFOBUFSIZE (128 * 1024) - static char CpuInfoBuf[ CPUINFOBUFSIZE ]; - static int Dirty = 0; - static struct SensorModul *CpuInfoSM; diff --git a/SPECS/kde-workspace.spec b/SPECS/kde-workspace.spec index bb26be5..422da7e 100755 --- a/SPECS/kde-workspace.spec +++ b/SPECS/kde-workspace.spec @@ -22,7 +22,7 @@ Summary: KDE Workspace Name: kde-workspace Version: 4.11.19 -Release: 15%{?dist} +Release: 16%{?dist} License: GPLv2 URL: https://projects.kde.org/projects/kde/kde-workspace Source0: http://download.kde.org/stable/applications/src/14.12.1/kde-workspace-%{version}.tar.xz @@ -174,7 +174,7 @@ Patch70: kde-workspace-kscreenlocker-greeter-unlock-just-once.patch Patch71: kde-workspace-sanitise-notification-html.patch # Bug 1611762 - ksysguardd: "internal buffer too small to read /proc/cpuinfo" when running with many CPUs -Patch72: kde-workspace-ksysguard-increase-cpu-buffer.patch +Patch72: kde-workspace-ksysguard-grow-buffer-size-as-needed.patch # Bug 1677641 - Plastik theme shows defunct close button on non deletable gtk window Patch73: kde-workspace-plastik-do-not-show-disabled-buttons.patch @@ -618,7 +618,7 @@ Conflicts: kde-workspace < 4.11.15-3 %patch69 -p1 -b .taskmanager-grouping %patch70 -p1 -b .kscreenlocker-greeter-unlock-just-once %patch71 -p1 -b .sanitise-notification-html -%patch72 -p1 -b .ksysguard-increase-cpu-buffer +%patch72 -p1 -b .ksysguard-grow-buffer-size-as-needed %patch73 -p1 -b .plastik-do-not-show-disabled-buttons %patch74 -p1 -b .taskmanager-check-if-full-when-item-from-group-is-removed @@ -1388,6 +1388,10 @@ fi %endif %changelog +* Tue Jul 14 2020 Jan Grulich - 4.11.19-16 +- KSysguard: Increase cpu buffer size in ksysguard + Resolves: bz#1856159 + * Wed Dec 04 2019 Jan Grulich - 4.11.19-15 - Fix curly bracket in the patch for Plastik decoration theme Resolves: bz#1779401