summaryrefslogtreecommitdiff
path: root/core/procps/procps-3.2.8-threads.patch
diff options
context:
space:
mode:
Diffstat (limited to 'core/procps/procps-3.2.8-threads.patch')
-rw-r--r--core/procps/procps-3.2.8-threads.patch49
1 files changed, 49 insertions, 0 deletions
diff --git a/core/procps/procps-3.2.8-threads.patch b/core/procps/procps-3.2.8-threads.patch
new file mode 100644
index 000000000..2491aa4c0
--- /dev/null
+++ b/core/procps/procps-3.2.8-threads.patch
@@ -0,0 +1,49 @@
+diff -up procps-3.2.8/top.c.threads procps-3.2.8/top.c
+--- procps-3.2.8/top.c.threads 2009-10-01 07:14:43.000000000 -0400
++++ procps-3.2.8/top.c 2009-10-05 14:05:00.000000000 -0400
+@@ -1138,6 +1138,7 @@ static proc_t **procs_refresh (proc_t **
+ #define ENTsz sizeof(proc_t)
+ static unsigned savmax = 0; // first time, Bypass: (i)
+ proc_t *ptsk = (proc_t *)-1; // first time, Force: (ii)
++ proc_t *saved_ptsk;
+ unsigned curmax = 0; // every time (jeeze)
+ PROCTAB* PT;
+ static int show_threads_was_enabled = 0; // optimization
+@@ -1172,6 +1173,10 @@ static proc_t **procs_refresh (proc_t **
+ while (curmax < savmax) {
+ proc_t *ttsk;
+ if (unlikely(!(ptsk = readproc(PT, NULL)))) break;
++ if(!show_threads_was_enabled)
++ saved_ptsk = ptsk;
++ else
++ saved_ptsk = NULL;
+ show_threads_was_enabled = 1;
+ while (curmax < savmax) {
+ unsigned idx;
+@@ -1189,7 +1194,7 @@ static proc_t **procs_refresh (proc_t **
+ prochlp(ttsk);
+ ++curmax;
+ }
+- free(ptsk); // readproc() proc_t not used
++ if(!saved_ptsk) free(ptsk); // readproc() proc_t not used
+ }
+ }
+
+@@ -1208,7 +1213,8 @@ static proc_t **procs_refresh (proc_t **
+ else { // show each thread in a process separately
+ while (ptsk) {
+ proc_t *ttsk;
+- if (likely(ptsk = readproc(PT, NULL))) {
++ if (likely(ptsk = readproc(PT, NULL)) ||
++ unlikely(saved_ptsk && (ptsk = saved_ptsk)) ) {
+ show_threads_was_enabled = 1;
+ while (1) {
+ table = alloc_r(table, (curmax + 1) * PTRsz);
+@@ -1216,6 +1222,7 @@ static proc_t **procs_refresh (proc_t **
+ prochlp(ttsk);
+ table[curmax++] = ttsk;
+ }
++ saved_ptsk = NULL;
+ free(ptsk); // readproc() proc_t not used
+ }
+ }