Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/make Fix meta_compat mode.
details: https://anonhg.NetBSD.org/src/rev/504453a71558
branches: trunk
changeset: 744549:504453a71558
user: sjg <sjg%NetBSD.org@localhost>
date: Thu Feb 06 01:13:19 2020 +0000
description:
Fix meta_compat mode.
We need to call meta_job_output() from meta_compat_parent()
Also, the need for extra fds for meta mode only applies when
using filemon_ktrace.c.
Since we hope to see more interfaces like that, test for
USE_FILEMON_DEV being not defined.
Reviewed by: riastradh
diffstat:
usr.bin/make/Makefile | 6 +++---
usr.bin/make/job.c | 16 ++++++++--------
usr.bin/make/meta.c | 19 +++++++++----------
3 files changed, 20 insertions(+), 21 deletions(-)
diffs (169 lines):
diff -r 949c95e576fa -r 504453a71558 usr.bin/make/Makefile
--- a/usr.bin/make/Makefile Thu Feb 06 00:32:07 2020 +0000
+++ b/usr.bin/make/Makefile Thu Feb 06 01:13:19 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.68 2020/01/19 19:50:54 riastradh Exp $
+# $NetBSD: Makefile,v 1.69 2020/02/06 01:13:19 sjg Exp $
# @(#)Makefile 5.2 (Berkeley) 12/28/90
PROG= make
@@ -24,7 +24,7 @@
.PATH: ${.CURDIR}/filemon
SRCS+= filemon_${USE_FILEMON}.c
-CPPFLAGS+= -DUSE_FILEMON
+CPPFLAGS+= -DUSE_FILEMON -DUSE_FILEMON_${USE_FILEMON:tu}
.if ${USE_FILEMON} == "dev"
FILEMON_H ?= /usr/include/dev/filemon/filemon.h
@@ -67,5 +67,5 @@
COPTS.parse.c+= ${GCC_NO_FORMAT_TRUNCATION}
# A simple unit-test driver to help catch regressions
-accept test:
+accept test: .MAKE
cd ${.CURDIR}/unit-tests && MAKEFLAGS= ${.MAKE} -r -m / TEST_MAKE=${TEST_MAKE:U${.OBJDIR}/${PROG:T}} ${.TARGET}
diff -r 949c95e576fa -r 504453a71558 usr.bin/make/job.c
--- a/usr.bin/make/job.c Thu Feb 06 00:32:07 2020 +0000
+++ b/usr.bin/make/job.c Thu Feb 06 01:13:19 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: job.c,v 1.196 2020/01/19 19:42:32 riastradh Exp $ */
+/* $NetBSD: job.c,v 1.197 2020/02/06 01:13:19 sjg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: job.c,v 1.196 2020/01/19 19:42:32 riastradh Exp $";
+static char rcsid[] = "$NetBSD: job.c,v 1.197 2020/02/06 01:13:19 sjg Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)job.c 8.2 (Berkeley) 3/19/94";
#else
-__RCSID("$NetBSD: job.c,v 1.196 2020/01/19 19:42:32 riastradh Exp $");
+__RCSID("$NetBSD: job.c,v 1.197 2020/02/06 01:13:19 sjg Exp $");
#endif
#endif /* not lint */
#endif
@@ -362,7 +362,7 @@
static unsigned
nfds_per_job(void)
{
-#ifdef USE_META
+#if defined(USE_FILEMON) && !defined(USE_FILEMON_DEV)
if (useMeta)
return 2;
#endif
@@ -2145,7 +2145,7 @@
job = jobfds[i];
if (job->job_state == JOB_ST_RUNNING)
JobDoOutput(job, FALSE);
-#ifdef USE_META
+#if defined(USE_FILEMON) && !defined(USE_FILEMON_DEV)
/*
* With meta mode, we may have activity on the job's filemon
* descriptor too, which at the moment is any pollfd other than
@@ -2824,7 +2824,7 @@
jobfds[nfds] = job;
job->inPollfd = &fds[nfds];
nfds++;
-#ifdef USE_META
+#if defined(USE_FILEMON) && !defined(USE_FILEMON_DEV)
if (useMeta) {
fds[nfds].fd = meta_job_fd(job);
fds[nfds].events = fds[nfds].fd == -1 ? 0 : POLLIN;
@@ -2842,7 +2842,7 @@
Punt("Unwatching unwatched job");
i = job->inPollfd - fds;
nfds--;
-#ifdef USE_META
+#if defined(USE_FILEMON) && !defined(USE_FILEMON_DEV)
if (useMeta) {
/*
* Sanity check: there should be two fds per job, so the job's
@@ -2861,7 +2861,7 @@
fds[i] = fds[nfds];
jobfds[i] = jobfds[nfds];
jobfds[i]->inPollfd = &fds[i];
-#ifdef USE_META
+#if defined(USE_FILEMON) && !defined(USE_FILEMON_DEV)
if (useMeta) {
fds[i + 1] = fds[nfds + 1];
jobfds[i + 1] = jobfds[nfds + 1];
diff -r 949c95e576fa -r 504453a71558 usr.bin/make/meta.c
--- a/usr.bin/make/meta.c Thu Feb 06 00:32:07 2020 +0000
+++ b/usr.bin/make/meta.c Thu Feb 06 01:13:19 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: meta.c,v 1.77 2020/01/22 21:04:29 sjg Exp $ */
+/* $NetBSD: meta.c,v 1.78 2020/02/06 01:13:19 sjg Exp $ */
/*
* Implement 'meta' mode.
@@ -716,7 +716,7 @@
void
meta_job_parent(Job *job, pid_t pid)
{
-#ifdef USE_FILEMON
+#if defined(USE_FILEMON) && !defined(USE_FILEMON_DEV)
BuildMon *pbm;
if (job != NULL) {
@@ -733,7 +733,7 @@
int
meta_job_fd(Job *job)
{
-#ifdef USE_FILEMON
+#if defined(USE_FILEMON) && !defined(USE_FILEMON_DEV)
BuildMon *pbm;
if (job != NULL) {
@@ -751,7 +751,7 @@
int
meta_job_event(Job *job)
{
-#ifdef USE_FILEMON
+#if defined(USE_FILEMON) && !defined(USE_FILEMON_DEV)
BuildMon *pbm;
if (job != NULL) {
@@ -1680,16 +1680,13 @@
meta_compat_parent(pid_t child)
{
int outfd, metafd, maxfd, nfds;
- char buf[BUFSIZ];
+ char buf[BUFSIZ+1];
fd_set readfds;
meta_job_parent(NULL, child);
close(childPipe[1]); /* child side */
outfd = childPipe[0];
- if (!Mybm.filemon) /* no meta */
- return;
- metafd = filemon_readfd(Mybm.filemon);
-
+ metafd = Mybm.filemon ? filemon_readfd(Mybm.filemon) : -1;
maxfd = -1;
if (outfd > maxfd)
maxfd = outfd;
@@ -1713,7 +1710,7 @@
if (outfd != -1 && FD_ISSET(outfd, &readfds)) do {
/* XXX this is not line-buffered */
- ssize_t nread = read(outfd, buf, sizeof buf);
+ ssize_t nread = read(outfd, buf, sizeof(buf) - 1);
if (nread == -1)
err(1, "read");
if (nread == 0) {
@@ -1723,6 +1720,8 @@
}
fwrite(buf, 1, (size_t)nread, stdout);
fflush(stdout);
+ buf[nread] = '\0';
+ meta_job_output(NULL, buf, "");
} while (0);
if (metafd != -1 && FD_ISSET(metafd, &readfds)) {
if (meta_job_event(NULL) <= 0)
Home |
Main Index |
Thread Index |
Old Index