updated on Thu Jan 19 20:01:47 UTC 2012
[aur-mirror.git] / selinux-procps / procps-3.2.8-threads.patch
blob2491aa4c00133a358b15dcfd4bb4fa122a841e76
1 diff -up procps-3.2.8/top.c.threads procps-3.2.8/top.c
2 --- procps-3.2.8/top.c.threads 2009-10-01 07:14:43.000000000 -0400
3 +++ procps-3.2.8/top.c 2009-10-05 14:05:00.000000000 -0400
4 @@ -1138,6 +1138,7 @@ static proc_t **procs_refresh (proc_t **
5 #define ENTsz sizeof(proc_t)
6 static unsigned savmax = 0; // first time, Bypass: (i)
7 proc_t *ptsk = (proc_t *)-1; // first time, Force: (ii)
8 + proc_t *saved_ptsk;
9 unsigned curmax = 0; // every time (jeeze)
10 PROCTAB* PT;
11 static int show_threads_was_enabled = 0; // optimization
12 @@ -1172,6 +1173,10 @@ static proc_t **procs_refresh (proc_t **
13 while (curmax < savmax) {
14 proc_t *ttsk;
15 if (unlikely(!(ptsk = readproc(PT, NULL)))) break;
16 + if(!show_threads_was_enabled)
17 + saved_ptsk = ptsk;
18 + else
19 + saved_ptsk = NULL;
20 show_threads_was_enabled = 1;
21 while (curmax < savmax) {
22 unsigned idx;
23 @@ -1189,7 +1194,7 @@ static proc_t **procs_refresh (proc_t **
24 prochlp(ttsk);
25 ++curmax;
27 - free(ptsk); // readproc() proc_t not used
28 + if(!saved_ptsk) free(ptsk); // readproc() proc_t not used
32 @@ -1208,7 +1213,8 @@ static proc_t **procs_refresh (proc_t **
33 else { // show each thread in a process separately
34 while (ptsk) {
35 proc_t *ttsk;
36 - if (likely(ptsk = readproc(PT, NULL))) {
37 + if (likely(ptsk = readproc(PT, NULL)) ||
38 + unlikely(saved_ptsk && (ptsk = saved_ptsk)) ) {
39 show_threads_was_enabled = 1;
40 while (1) {
41 table = alloc_r(table, (curmax + 1) * PTRsz);
42 @@ -1216,6 +1222,7 @@ static proc_t **procs_refresh (proc_t **
43 prochlp(ttsk);
44 table[curmax++] = ttsk;
46 + saved_ptsk = NULL;
47 free(ptsk); // readproc() proc_t not used