diff options
author | Fabian Groffen <grobian@gentoo.org> | 2018-04-04 15:13:15 +0200 |
---|---|---|
committer | Fabian Groffen <grobian@gentoo.org> | 2018-04-04 15:13:15 +0200 |
commit | 80d7de29b2c1f977e84bc653933545a6eb589694 (patch) | |
tree | 52df23015321095241c0eb5a75816d7cf521fcf5 | |
parent | qfile_main: use q_vdb_foreach_pkg_sorted, bug #607498 (diff) | |
download | portage-utils-80d7de29b2c1f977e84bc653933545a6eb589694.tar.gz portage-utils-80d7de29b2c1f977e84bc653933545a6eb589694.tar.bz2 portage-utils-80d7de29b2c1f977e84bc653933545a6eb589694.zip |
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
-rw-r--r-- | qlop.c | 30 |
1 files changed, 26 insertions, 4 deletions
@@ -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 |