pkgsrc-Changes archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
CVS commit: pkgsrc/devel/gmake
Module Name: pkgsrc
Committed By: bsiegert
Date: Wed Jul 4 14:09:07 UTC 2018
Modified Files:
pkgsrc/devel/gmake: Makefile distinfo
pkgsrc/devel/gmake/patches: patch-makeint.h
Added Files:
pkgsrc/devel/gmake/patches: patch-posixos.c
Log Message:
Patch SV 51159 in GNU Make.
Hopefully this will fix the problems joerg@ and others encountered last
time gmake was updated to 4.2.1. Description of the patch:
[SV 51159] Use a non-blocking read with pselect to avoid hangs.
* posixos.c (set_blocking): Set blocking on a file descriptor.
(jobserver_setup): Set non-blocking on the jobserver read side.
(jobserver_parse_auth): Ditto.
(jobserver_acquire_all): Set blocking to avoid a busy-wait loop.
(jobserver_acquire): If the non-blocking read() returns without
taking a token then try again.
To generate a diff of this commit:
cvs rdiff -u -r1.105 -r1.106 pkgsrc/devel/gmake/Makefile
cvs rdiff -u -r1.35 -r1.36 pkgsrc/devel/gmake/distinfo
cvs rdiff -u -r1.7 -r1.8 pkgsrc/devel/gmake/patches/patch-makeint.h
cvs rdiff -u -r0 -r1.1 pkgsrc/devel/gmake/patches/patch-posixos.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: pkgsrc/devel/gmake/Makefile
diff -u pkgsrc/devel/gmake/Makefile:1.105 pkgsrc/devel/gmake/Makefile:1.106
--- pkgsrc/devel/gmake/Makefile:1.105 Wed Jul 4 09:42:56 2018
+++ pkgsrc/devel/gmake/Makefile Wed Jul 4 14:09:07 2018
@@ -1,7 +1,8 @@
-# $NetBSD: Makefile,v 1.105 2018/07/04 09:42:56 bsiegert Exp $
+# $NetBSD: Makefile,v 1.106 2018/07/04 14:09:07 bsiegert Exp $
DISTNAME= make-4.2.1
PKGNAME= g${DISTNAME}
+PKGREVISION= 1
CATEGORIES= devel
MASTER_SITES= ${MASTER_SITE_GNU:=make/}
EXTRACT_SUFX= .tar.bz2
Index: pkgsrc/devel/gmake/distinfo
diff -u pkgsrc/devel/gmake/distinfo:1.35 pkgsrc/devel/gmake/distinfo:1.36
--- pkgsrc/devel/gmake/distinfo:1.35 Wed Jul 4 09:42:56 2018
+++ pkgsrc/devel/gmake/distinfo Wed Jul 4 14:09:07 2018
@@ -1,4 +1,4 @@
-$NetBSD: distinfo,v 1.35 2018/07/04 09:42:56 bsiegert Exp $
+$NetBSD: distinfo,v 1.36 2018/07/04 14:09:07 bsiegert Exp $
SHA1 (make-4.2.1.tar.bz2) = 7d9d11eb36cfb752da1fb11bb3e521d2a3cc8830
RMD160 (make-4.2.1.tar.bz2) = 7cf74e2fd9764ffeb48f40a49077099874ad8a54
@@ -10,3 +10,4 @@ SHA1 (patch-configure.ac) = 7d22c8f5e5d3
SHA1 (patch-dir.c) = 1616d8e26c0761c8734063806fa581ae8884b4e8
SHA1 (patch-makeint.h) = cb5f0889d84874a16fc10bc6f91e18c2277194cc
SHA1 (patch-pa) = 2c0168db7afec3da98b30392290e5b9464ea7b5e
+SHA1 (patch-posixos.c) = 4c566b23442bcc87f776181be531957c254162de
Index: pkgsrc/devel/gmake/patches/patch-makeint.h
diff -u pkgsrc/devel/gmake/patches/patch-makeint.h:1.7 pkgsrc/devel/gmake/patches/patch-makeint.h:1.8
--- pkgsrc/devel/gmake/patches/patch-makeint.h:1.7 Wed Jul 4 09:42:56 2018
+++ pkgsrc/devel/gmake/patches/patch-makeint.h Wed Jul 4 14:09:07 2018
@@ -1,4 +1,4 @@
-$NetBSD: patch-makeint.h,v 1.7 2018/07/04 09:42:56 bsiegert Exp $
+$NetBSD: patch-makeint.h,v 1.8 2018/07/04 14:09:07 bsiegert Exp $
* Do not override stack limits by default.
It can dramatically increase the memory use of multi-threaded programs.
Added files:
Index: pkgsrc/devel/gmake/patches/patch-posixos.c
diff -u /dev/null pkgsrc/devel/gmake/patches/patch-posixos.c:1.1
--- /dev/null Wed Jul 4 14:09:07 2018
+++ pkgsrc/devel/gmake/patches/patch-posixos.c Wed Jul 4 14:09:07 2018
@@ -0,0 +1,162 @@
+$NetBSD: patch-posixos.c,v 1.1 2018/07/04 14:09:07 bsiegert Exp $
+
+http://git.savannah.gnu.org/cgit/make.git/commit/?id=b552b05251980f693c729e251f93f5225b400714
+
+[SV 51159] Use a non-blocking read with pselect to avoid hangs.
+* posixos.c (set_blocking): Set blocking on a file descriptor.
+* (jobserver_setup): Set non-blocking on the jobserver read side.
+* (jobserver_parse_auth): Ditto.
+* (jobserver_acquire_all): Set blocking to avoid a busy-wait loop.
+* (jobserver_acquire): If the non-blocking read() returns without
+ taking a token then try again.
+
+--- posixos.c.orig 2016-05-21 20:21:52.000000000 +0000
++++ posixos.c
+@@ -59,6 +59,24 @@ make_job_rfd (void)
+ #endif
+ }
+
++static void
++set_blocking (int fd, int blocking)
++{
++ // If we're not using pselect() don't change the blocking
++#ifdef HAVE_PSELECT
++ int flags;
++ EINTRLOOP (flags, fcntl (fd, F_GETFL));
++ if (flags >= 0)
++ {
++ int r;
++ flags = blocking ? (flags & ~O_NONBLOCK) : (flags | O_NONBLOCK);
++ EINTRLOOP (r, fcntl (fd, F_SETFL, flags));
++ if (r < 0)
++ pfatal_with_name ("fcntl(O_NONBLOCK)");
++ }
++#endif
++}
++
+ unsigned int
+ jobserver_setup (int slots)
+ {
+@@ -78,6 +96,9 @@ jobserver_setup (int slots)
+ pfatal_with_name (_("init jobserver pipe"));
+ }
+
++ /* When using pselect() we want the read to be non-blocking. */
++ set_blocking (job_fds[0], 0);
++
+ return 1;
+ }
+
+@@ -113,6 +134,9 @@ jobserver_parse_auth (const char *auth)
+ return 0;
+ }
+
++ /* When using pselect() we want the read to be non-blocking. */
++ set_blocking (job_fds[0], 0);
++
+ return 1;
+ }
+
+@@ -161,7 +185,10 @@ jobserver_acquire_all (void)
+ {
+ unsigned int tokens = 0;
+
+- /* Close the write side, so the read() won't hang. */
++ /* Use blocking reads to wait for all outstanding jobs. */
++ set_blocking (job_fds[0], 1);
++
++ /* Close the write side, so the read() won't hang forever. */
+ close (job_fds[1]);
+ job_fds[1] = -1;
+
+@@ -239,18 +266,12 @@ jobserver_pre_acquire (void)
+ unsigned int
+ jobserver_acquire (int timeout)
+ {
+- sigset_t empty;
+- fd_set readfds;
+ struct timespec spec;
+ struct timespec *specp = NULL;
+- int r;
+- char intake;
++ sigset_t empty;
+
+ sigemptyset (&empty);
+
+- FD_ZERO (&readfds);
+- FD_SET (job_fds[0], &readfds);
+-
+ if (timeout)
+ {
+ /* Alarm after one second (is this too granular?) */
+@@ -259,28 +280,52 @@ jobserver_acquire (int timeout)
+ specp = &spec;
+ }
+
+- r = pselect (job_fds[0]+1, &readfds, NULL, NULL, specp, &empty);
+-
+- if (r == -1)
++ while (1)
+ {
+- /* Better be SIGCHLD. */
+- if (errno != EINTR)
+- pfatal_with_name (_("pselect jobs pipe"));
+- return 0;
+- }
++ fd_set readfds;
++ int r;
++ char intake;
+
+- if (r == 0)
+- /* Timeout. */
+- return 0;
++ FD_ZERO (&readfds);
++ FD_SET (job_fds[0], &readfds);
+
+- /* The read FD is ready: read it! */
+- EINTRLOOP (r, read (job_fds[0], &intake, 1));
+- if (r < 0)
+- pfatal_with_name (_("read jobs pipe"));
++ r = pselect (job_fds[0]+1, &readfds, NULL, NULL, specp, &empty);
++ if (r < 0)
++ switch (errno)
++ {
++ case EINTR:
++ /* SIGCHLD will show up as an EINTR. */
++ return 0;
++
++ case EBADF:
++ /* Someone closed the jobs pipe.
++ That shouldn't happen but if it does we're done. */
++ O (fatal, NILF, _("job server shut down"));
++
++ default:
++ pfatal_with_name (_("pselect jobs pipe"));
++ }
++
++ if (r == 0)
++ /* Timeout. */
++ return 0;
++
++ /* The read FD is ready: read it! This is non-blocking. */
++ EINTRLOOP (r, read (job_fds[0], &intake, 1));
++
++ if (r < 0)
++ {
++ /* Someone sniped our token! Try again. */
++ if (errno == EAGAIN)
++ continue;
++
++ pfatal_with_name (_("read jobs pipe"));
++ }
+
+- /* What does it mean if read() returns 0? It shouldn't happen because only
+- the master make can reap all the tokens and close the write side...?? */
+- return r > 0;
++ /* read() should never return 0: only the master make can reap all the
++ tokens and close the write side...?? */
++ return r > 0;
++ }
+ }
+
+ #else
Home |
Main Index |
Thread Index |
Old Index