commit:     ca7402e12d1e149a7f2a3dee985c4e17dde6e28e
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Thu Jun  6 13:44:23 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu Jun  6 13:44:23 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=ca7402e1

qlop: prune running packages list more often

When we don't have proof that Portage started, but we see it finishing,
prune the entire list of unfinished packages, in order to deal with
truncated/rotated logs.

Bug: https://bugs.gentoo.org/687508
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qlop.c | 40 +++++++++++++++++++++++-----------------
 1 file changed, 23 insertions(+), 17 deletions(-)

diff --git a/qlop.c b/qlop.c
index a3b4d53..c356e6b 100644
--- a/qlop.c
+++ b/qlop.c
@@ -450,23 +450,29 @@ static int do_emerge_log(
                                parallel_emerge++;
                        } else if (parallel_emerge > 0) {
                                parallel_emerge--;
-                               if (parallel_emerge == 0) {
-                                       /* we just finished the only emerge we 
found to be
-                                        * running, so if there were "running" 
(unfinished)
-                                        * merges, they must have been 
terminated */
-                                       sync_start = 0;
-                                       while ((i = array_cnt(merge_matches)) > 
0) {
-                                               i--;
-                                               pkgw = xarrayget(merge_matches, 
i);
-                                               atom_implode(pkgw->atom);
-                                               xarraydelete(merge_matches, i);
-                                       }
-                                       while ((i = array_cnt(unmerge_matches)) 
> 0) {
-                                               i--;
-                                               pkgw = 
xarrayget(unmerge_matches, i);
-                                               atom_implode(pkgw->atom);
-                                               xarraydelete(unmerge_matches, 
i);
-                                       }
+                       }
+                       
+                       /* for bug #687508, this cannot be in the else if case
+                        * above, if the log is truncated somehow, the leading
+                        * *** emerge might be missing, but a termination in 
that
+                        * case better means we forget about everything that was
+                        * unfinished not to keep reporting some packages 
forever */
+                       if (parallel_emerge == 0) {
+                               /* we just finished the only emerge we found to 
be
+                                * running, so if there were "running" 
(unfinished)
+                                * merges, they must have been terminated */
+                               sync_start = 0;
+                               while ((i = array_cnt(merge_matches)) > 0) {
+                                       i--;
+                                       pkgw = xarrayget(merge_matches, i);
+                                       atom_implode(pkgw->atom);
+                                       xarraydelete(merge_matches, i);
+                               }
+                               while ((i = array_cnt(unmerge_matches)) > 0) {
+                                       i--;
+                                       pkgw = xarrayget(unmerge_matches, i);
+                                       atom_implode(pkgw->atom);
+                                       xarraydelete(unmerge_matches, i);
                                }
                        }
                }

Reply via email to