pkgsrc-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

CVS commit: pkgsrc/www/fcgiwrap



Module Name:    pkgsrc
Committed By:   riastradh
Date:           Tue Oct  6 03:15:01 UTC 2026

Modified Files:
        pkgsrc/www/fcgiwrap: Makefile distinfo
        pkgsrc/www/fcgiwrap/files: fcgiwrap.sh
        pkgsrc/www/fcgiwrap/patches: patch-fcgiwrap.c

Log Message:
www/fcgiwrap: Fix various issues with multiple children and rc.d.

- With `-c <n>', don't start spinning the CPU at 100% from the time
  the first child exits to the time the operator gives up and kills
  fcgiwrap altogether.

- Fix races with SIGCHLD handler.

- Allow rc.d script to spawn multiple children with new
  `fcgiwrap_nchildren' option (default 1).

- Redirect stdin from /dev/null, at least, in rc.d script, in lieu of
  either
  (a) proper daemonization and syslogging or
  (b) running under a process supervisor.

PR pkg/60853: www/fcgiwrap rc.d woes


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 pkgsrc/www/fcgiwrap/Makefile \
    pkgsrc/www/fcgiwrap/distinfo
cvs rdiff -u -r1.3 -r1.4 pkgsrc/www/fcgiwrap/files/fcgiwrap.sh
cvs rdiff -u -r1.1 -r1.2 pkgsrc/www/fcgiwrap/patches/patch-fcgiwrap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: pkgsrc/www/fcgiwrap/Makefile
diff -u pkgsrc/www/fcgiwrap/Makefile:1.5 pkgsrc/www/fcgiwrap/Makefile:1.6
--- pkgsrc/www/fcgiwrap/Makefile:1.5    Thu Aug 28 04:27:31 2025
+++ pkgsrc/www/fcgiwrap/Makefile        Tue Oct  6 03:15:00 2026
@@ -1,7 +1,7 @@
-# $NetBSD: Makefile,v 1.5 2025/08/28 04:27:31 khorben Exp $
+# $NetBSD: Makefile,v 1.6 2026/10/06 03:15:00 riastradh Exp $
 
 DISTNAME=      fcgiwrap-1.1.0
-PKGREVISION=   3
+PKGREVISION=   4
 CATEGORIES=    www
 
 COMMENT=       FastCGI wrapper for plain CGI scripts
Index: pkgsrc/www/fcgiwrap/distinfo
diff -u pkgsrc/www/fcgiwrap/distinfo:1.5 pkgsrc/www/fcgiwrap/distinfo:1.6
--- pkgsrc/www/fcgiwrap/distinfo:1.5    Tue Oct 26 11:29:26 2021
+++ pkgsrc/www/fcgiwrap/distinfo        Tue Oct  6 03:15:00 2026
@@ -1,7 +1,7 @@
-$NetBSD: distinfo,v 1.5 2021/10/26 11:29:26 nia Exp $
+$NetBSD: distinfo,v 1.6 2026/10/06 03:15:00 riastradh Exp $
 
 BLAKE2s (fcgiwrap-1.1.0.tar.gz) = 2df86367a0522d43c39f1cf4db5f5c89107bfcb7aab7755c2505da4babb72732
 SHA512 (fcgiwrap-1.1.0.tar.gz) = b8d35762d1d3c94a67602290b0092f0c38cffbbcd3dbc16597abf8b92172909b04450c238de2e430e841a17dd47fdd48d6a001f77539966980ef1af61e447ddc
 Size (fcgiwrap-1.1.0.tar.gz) = 9924 bytes
 SHA1 (patch-Makefile.in) = 30615f4beb33f9ac47fdcd7cebb93bd42fa55e94
-SHA1 (patch-fcgiwrap.c) = 5c5643015cc42d27774885becf6c91002f889cca
+SHA1 (patch-fcgiwrap.c) = aaa12ba5370b71ecf31ac3801bc9915e377608b2

Index: pkgsrc/www/fcgiwrap/files/fcgiwrap.sh
diff -u pkgsrc/www/fcgiwrap/files/fcgiwrap.sh:1.3 pkgsrc/www/fcgiwrap/files/fcgiwrap.sh:1.4
--- pkgsrc/www/fcgiwrap/files/fcgiwrap.sh:1.3   Thu Aug 28 04:27:31 2025
+++ pkgsrc/www/fcgiwrap/files/fcgiwrap.sh       Tue Oct  6 03:15:00 2026
@@ -1,6 +1,6 @@
 #!@RCD_SCRIPTS_SHELL@
 #
-# $NetBSD: fcgiwrap.sh,v 1.3 2025/08/28 04:27:31 khorben Exp $
+# $NetBSD: fcgiwrap.sh,v 1.4 2026/10/06 03:15:00 riastradh Exp $
 #
 # PROVIDE: fcgiwrap
 # REQUIRE: DAEMON
@@ -21,6 +21,7 @@ start_precmd="fcgiwrap_precmd"
 start_cmd="fcgiwrap_start"
 start_postcmd="fcgiwrap_poststart"
 fcgiwrap_socket="@VARBASE@/run/${name}/${name}.sock"
+fcgiwrap_nchildren=1
 
 fcgiwrap_precmd()
 {
@@ -37,7 +38,22 @@ fcgiwrap_precmd()
 fcgiwrap_start()
 {
        echo "Starting ${name}."
-       @SU@ -m ${fcgiwrap_user} -c "${command} -f -s unix:${fcgiwrap_socket}" &
+
+        # XXX This should really either:
+        #
+        # (a) properly daemonize and log to syslog, or
+        # (b) run under a process supervisor.
+        #
+        # But fcgiwrap doesn't do (a), and rc.d doesn't have (b).
+        #
+        # As a partial measure, we redirect stdin from /dev/null so it
+        # doesn't try to read from the tty of whoever runs `service
+        # fcgiwrap start'.  But if it prints error output during the
+        # startup, we really want the operator to see that unless
+        # they've already closed the terminal.  So don't redirect
+        # stdout or stderr to /dev/null.
+        #
+       @SU@ -m ${fcgiwrap_user} -c "${command} ${fcgiwrap_flags} -c ${fcgiwrap_nchildren} -f -s unix:${fcgiwrap_socket} </dev/null" &
 }
 
 fcgiwrap_poststart() {

Index: pkgsrc/www/fcgiwrap/patches/patch-fcgiwrap.c
diff -u pkgsrc/www/fcgiwrap/patches/patch-fcgiwrap.c:1.1 pkgsrc/www/fcgiwrap/patches/patch-fcgiwrap.c:1.2
--- pkgsrc/www/fcgiwrap/patches/patch-fcgiwrap.c:1.1    Wed Nov 28 16:06:36 2018
+++ pkgsrc/www/fcgiwrap/patches/patch-fcgiwrap.c        Tue Oct  6 03:15:00 2026
@@ -1,6 +1,12 @@
-$NetBSD: patch-fcgiwrap.c,v 1.1 2018/11/28 16:06:36 jperkin Exp $
+$NetBSD: patch-fcgiwrap.c,v 1.2 2026/10/06 03:15:00 riastradh Exp $
 
-Appease -Werror=implicit-fallthrough.
+1. Appease -Werror=implicit-fallthrough.
+
+2. Fix 100% CPU usage as soon as  child exits:
+   https://github.com/gnosek/fcgiwrap/issues/18
+   https://github.com/gnosek/fcgiwrap/pull/20
+
+3-4. Fix races with SIGCHLD handler around access to nrunning.
 
 --- fcgiwrap.c.orig    2013-02-03 13:25:17.000000000 +0000
 +++ fcgiwrap.c
@@ -13,3 +19,44 @@ Appease -Werror=implicit-fallthrough.
                default: /* parent */
                        close(pipe_in[0]);
                        close(pipe_out[1]);
+@@ -605,7 +605,7 @@ static void sigchld_handler(int dummy)
+ {
+       int status;
+ 
+-      while ((dummy = waitpid(-1, &status, WNOHANG)) != -1) {
++      while ((dummy = waitpid(-1, &status, WNOHANG)) > 0) {
+               /* sanity check */
+               if (nrunning > 0)
+                       nrunning--;
+@@ -619,17 +619,22 @@ static void sigchld_handler(int dummy)
+ static void prefork(int nchildren)
+ {
+       int startup = 1;
++      sigset_t mask, omask;
+ 
+       if (nchildren == 1) {
+               return;
+       }
+ 
++      sigemptyset(&mask);
++      sigaddset(&mask, SIGCHLD);
++      sigprocmask(SIG_BLOCK, &mask, &omask);
+       signal(SIGCHLD, sigchld_handler);
+ 
+       while (1) {
+               while (nrunning < nchildren) {
+                       pid_t pid = fork();
+                       if (pid == 0) {
++                              sigprocmask(SIG_SETMASK, &omask, NULL);
+                               return;
+                       } else if (pid != -1) {
+                               nrunning++;
+@@ -644,7 +649,7 @@ static void prefork(int nchildren)
+                       }
+               }
+               startup = 0;
+-              pause();
++              sigsuspend(&omask);
+       }
+ }
+ 



Home | Main Index | Thread Index | Old Index