From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 691971382C5 for ; Wed, 4 Apr 2018 13:16:29 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 6A983E0B46; Wed, 4 Apr 2018 13:16:28 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 30DC3E0B46 for ; Wed, 4 Apr 2018 13:16:28 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 1346F335C0A for ; Wed, 4 Apr 2018 13:16:27 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 004D7277 for ; Wed, 4 Apr 2018 13:16:24 +0000 (UTC) From: "Fabian Groffen" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Fabian Groffen" Message-ID: <1522847595.80d7de29b2c1f977e84bc653933545a6eb589694.grobian@gentoo> Subject: [gentoo-commits] proj/portage-utils:master commit in: / X-VCS-Repository: proj/portage-utils X-VCS-Files: qlop.c X-VCS-Directories: / X-VCS-Committer: grobian X-VCS-Committer-Name: Fabian Groffen X-VCS-Revision: 80d7de29b2c1f977e84bc653933545a6eb589694 X-VCS-Branch: master Date: Wed, 4 Apr 2018 13:16:24 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 882e16cd-3ce1-42a9-956d-f47cdea78344 X-Archives-Hash: 2ac00935047dee61d6a7efd0dc3e0e4e commit: 80d7de29b2c1f977e84bc653933545a6eb589694 Author: Fabian Groffen gentoo org> AuthorDate: Wed Apr 4 13:13:15 2018 +0000 Commit: Fabian Groffen gentoo org> CommitDate: Wed Apr 4 13:13:15 2018 +0000 URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=80d7de29 show_merge_times: start counting parallel merges from start of the file If we start counting parallel merges only once we found something interesting, we might not be aware of other emerges at that time, drawing wrong conclusions when seeing a termination message. Bug: https://bugs.gentoo.org/603024 qlop.c | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/qlop.c b/qlop.c index 464a488..63bdb7f 100644 --- a/qlop.c +++ b/qlop.c @@ -105,6 +105,7 @@ show_merge_times(char *package, const char *logfile, int average, char human_rea } /* loop over lines searching for cat/pkg */ + parallel_emerge = 0; while (fgets(buf[0], sizeof(buf[0]), fp) != NULL) { if ((p = strchr(buf[0], '\n')) != NULL) *p = '\0'; @@ -121,6 +122,25 @@ show_merge_times(char *package, const char *logfile, int average, char human_rea /* copy message (stripping timestamp) */ strncpy(buf[1], p, BUFSIZ); rmspace(buf[1]); + + if (strncmp(buf[1], "Started emerge on:", 18) == 0) { + /* a parallel emerge was launched */ + parallel_emerge++; + continue; + } + + if (strncmp(buf[1], "*** terminating.", 16) == 0) { + if (parallel_emerge > 0) { + /* a parallel emerge has finished */ + parallel_emerge--; + continue; + } else { + /* the main emerge was stopped? if there's more lines + * this file is just corrupt or truncated at the front */ + continue; + } + } + if (strncmp(buf[1], ">>> emerge (", 12) == 0) { /* construct the matching end marker */ snprintf(ep, BUFSIZ, "completed %s", &buf[1][4]); @@ -150,7 +170,6 @@ show_merge_times(char *package, const char *logfile, int average, char human_rea (strcmp(pkg, atom->PN) == 0))) || (strcmp(pkg, atom->PN) == 0)) { - parallel_emerge = 0; while (fgets(buf[0], sizeof(buf[0]), fp) != NULL) { if ((p = strchr(buf[0], '\n')) != NULL) *p = '\0'; @@ -173,14 +192,17 @@ show_merge_times(char *package, const char *logfile, int average, char human_rea /* a parallel emerge has finished */ parallel_emerge--; continue; - } else - /* the main emerge was stopped */ + } else { + /* the main emerge was stopped? if there's + * more lines this file is just corrupt or + * truncated at the front */ break; + } } /* pay attention to malformed log files (when the * end of an emerge process is not indicated by the - * line '*** terminating'). We assume than the log + * line '*** terminating'). We assume that the log * is malformed when we find a parallel emerge * process which is trying to emerge the same * package