From 45f33ab2b2f3f9436d40a229bf4ac6dca9411c05 Mon Sep 17 00:00:00 2001 From: "Simon J. Gerraty" Date: Wed, 5 Jun 2013 15:51:46 +0000 Subject: [PATCH] Import bmake-20130604 --- ChangeLog | 13 +++++++++++++ Makefile | 4 ++-- job.c | 26 ++++++++++++++------------ make.1 | 11 +++++++++-- var.c | 10 ++++------ 5 files changed, 42 insertions(+), 22 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0af20cade14a..587c7f90ad71 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2013-06-04 Simon J. Gerraty + + * Makefile (MAKE_VERSION): 20130604 + Merge with NetBSD make, pick up + o job.c: JobCreatePipe: do fcntl() after any tweaking of fd's + to avoid leaking descriptors. + +2013-05-28 Simon J. Gerraty + + * Makefile (MAKE_VERSION): 20130528 + Merge with NetBSD make, pick up + o var.c: cleanup some left-overs in VarHash() + 2013-05-20 Simon J. Gerraty * Makefile (MAKE_VERSION): 20130520 diff --git a/Makefile b/Makefile index 084142a2f401..c4bcfa428a4e 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ -# $Id: Makefile,v 1.12 2013/05/20 16:05:10 sjg Exp $ +# $Id: Makefile,v 1.14 2013/06/05 04:03:22 sjg Exp $ # Base version on src date -MAKE_VERSION= 20130520 +MAKE_VERSION= 20130604 PROG= bmake diff --git a/job.c b/job.c index a77eaab107ba..a0e407cdfcf5 100644 --- a/job.c +++ b/job.c @@ -1,4 +1,4 @@ -/* $NetBSD: job.c,v 1.172 2013/03/05 22:01:43 christos Exp $ */ +/* $NetBSD: job.c,v 1.173 2013/06/05 03:59:43 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.172 2013/03/05 22:01:43 christos Exp $"; +static char rcsid[] = "$NetBSD: job.c,v 1.173 2013/06/05 03:59:43 sjg Exp $"; #else #include #ifndef lint #if 0 static char sccsid[] = "@(#)job.c 8.2 (Berkeley) 3/19/94"; #else -__RCSID("$NetBSD: job.c,v 1.172 2013/03/05 22:01:43 christos Exp $"); +__RCSID("$NetBSD: job.c,v 1.173 2013/06/05 03:59:43 sjg Exp $"); #endif #endif /* not lint */ #endif @@ -414,6 +414,15 @@ JobCreatePipe(Job *job, int minfd) if (pipe(job->jobPipe) == -1) Punt("Cannot create pipe: %s", strerror(errno)); + for (i = 0; i < 2; i++) { + /* Avoid using low numbered fds */ + fd = fcntl(job->jobPipe[i], F_DUPFD, minfd); + if (fd != -1) { + close(job->jobPipe[i]); + job->jobPipe[i] = fd; + } + } + /* Set close-on-exec flag for both */ (void)fcntl(job->jobPipe[0], F_SETFD, 1); (void)fcntl(job->jobPipe[1], F_SETFD, 1); @@ -426,15 +435,6 @@ JobCreatePipe(Job *job, int minfd) */ fcntl(job->jobPipe[0], F_SETFL, fcntl(job->jobPipe[0], F_GETFL, 0) | O_NONBLOCK); - - for (i = 0; i < 2; i++) { - /* Avoid using low numbered fds */ - fd = fcntl(job->jobPipe[i], F_DUPFD, minfd); - if (fd != -1) { - close(job->jobPipe[i]); - job->jobPipe[i] = fd; - } - } } /*- @@ -2828,6 +2828,8 @@ Job_ServerStart(int max_tokens, int jp_0, int jp_1) /* Pipe passed in from parent */ tokenWaitJob.inPipe = jp_0; tokenWaitJob.outPipe = jp_1; + (void)fcntl(jp_0, F_SETFD, 1); + (void)fcntl(jp_1, F_SETFD, 1); return; } diff --git a/make.1 b/make.1 index 8c386826af1a..a2cc16a2bfdf 100644 --- a/make.1 +++ b/make.1 @@ -1,4 +1,4 @@ -.\" $NetBSD: make.1,v 1.213 2013/03/31 05:49:51 sjg Exp $ +.\" $NetBSD: make.1,v 1.215 2013/05/22 19:35:11 christos Exp $ .\" .\" Copyright (c) 1990, 1993 .\" The Regents of the University of California. All rights reserved. @@ -29,7 +29,7 @@ .\" .\" from: @(#)make.1 8.4 (Berkeley) 3/19/94 .\" -.Dd March 30, 2013 +.Dd May 22, 2013 .Dt MAKE 1 .Os .Sh NAME @@ -2110,6 +2110,13 @@ for Sprite at Berkeley. It was designed to be a parallel distributed make running jobs on different machines using a daemon called .Dq customs . +.Pp +Historically the target/dependency +.Dq FRC +has been used to FoRCe rebuilding (since the target/dependency +does not exist... unless someone creates an +.Dq FRC +file). .Sh BUGS The .Nm diff --git a/var.c b/var.c index fa58be6304df..d0d5266db497 100644 --- a/var.c +++ b/var.c @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.174 2013/05/18 13:12:45 sjg Exp $ */ +/* $NetBSD: var.c,v 1.175 2013/05/29 00:23:31 sjg Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -69,14 +69,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: var.c,v 1.174 2013/05/18 13:12:45 sjg Exp $"; +static char rcsid[] = "$NetBSD: var.c,v 1.175 2013/05/29 00:23:31 sjg Exp $"; #else #include #ifndef lint #if 0 static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 3/19/94"; #else -__RCSID("$NetBSD: var.c,v 1.174 2013/05/18 13:12:45 sjg Exp $"); +__RCSID("$NetBSD: var.c,v 1.175 2013/05/29 00:23:31 sjg Exp $"); #endif #endif /* not lint */ #endif @@ -2310,9 +2310,7 @@ VarHash(char *str) size_t len, len2; unsigned char *ustr = (unsigned char *)str; uint32_t h, k, c1, c2; - int done; - done = 1; h = 0x971e137bU; c1 = 0x95543787U; c2 = 0x2ad7eb25U; @@ -2342,7 +2340,7 @@ VarHash(char *str) h = (h << 13) ^ (h >> 19); h = h * 5 + 0x52dce729U; h ^= k; - } while (!done); + } h ^= len2; h *= 0x85ebca6b; h ^= h >> 13;