]> git.pld-linux.org Git - packages/lighttpd.git/commitdiff
- update to r2199:
authorElan Ruusamäe <glen@pld-linux.org>
Mon, 14 Jul 2008 15:49:34 +0000 (15:49 +0000)
committercvs2git <feedback@pld-linux.org>
Sun, 24 Jun 2012 12:13:13 +0000 (12:13 +0000)
  - merge spawn-fcgi changes from trunk (from @2191)
  - let spawn-fcgi propagate exit code from spawned fcgi application

Changed files:
    lighttpd-branch.diff -> 1.37

lighttpd-branch.diff

index 940e29cff422c4982c98e7836488c0473638b8c2..e25afaeed0fe0a409739b9db950eb50cf475e6cb 100644 (file)
@@ -1,7 +1,7 @@
 Index: lighttpd.spec.in
 ===================================================================
---- lighttpd.spec.in   (.../tags/lighttpd-1.4.19)      (revision 2190)
-+++ lighttpd.spec.in   (.../branches/lighttpd-1.4.x)   (revision 2190)
+--- lighttpd.spec.in   (.../tags/lighttpd-1.4.19)      (revision 2199)
++++ lighttpd.spec.in   (.../branches/lighttpd-1.4.x)   (revision 2199)
 @@ -1,83 +0,0 @@
 -Summary: A fast webserver with minimal memory-footprint (lighttpd)
 -Name: lighttpd
@@ -90,8 +90,8 @@ Index: configure.in
 ===================================================================
 Index: src/mod_ssi_exprparser.h
 ===================================================================
---- src/mod_ssi_exprparser.h   (.../tags/lighttpd-1.4.19)      (revision 2190)
-+++ src/mod_ssi_exprparser.h   (.../branches/lighttpd-1.4.x)   (revision 2190)
+--- src/mod_ssi_exprparser.h   (.../tags/lighttpd-1.4.19)      (revision 2199)
++++ src/mod_ssi_exprparser.h   (.../branches/lighttpd-1.4.x)   (revision 2199)
 @@ -1,12 +0,0 @@
 -#define TK_AND                             1
 -#define TK_OR                              2
@@ -107,8 +107,8 @@ Index: src/mod_ssi_exprparser.h
 -#define TK_VALUE                          12
 Index: src/configfile-glue.c
 ===================================================================
---- src/configfile-glue.c      (.../tags/lighttpd-1.4.19)      (revision 2190)
-+++ src/configfile-glue.c      (.../branches/lighttpd-1.4.x)   (revision 2190)
+--- src/configfile-glue.c      (.../tags/lighttpd-1.4.19)      (revision 2199)
++++ src/configfile-glue.c      (.../branches/lighttpd-1.4.x)   (revision 2199)
 @@ -529,7 +529,7 @@
  int config_append_cond_match_buffer(connection *con, data_config *dc, buffer *buf, int n)
  {
@@ -120,8 +120,8 @@ Index: src/configfile-glue.c
  
 Index: src/mod_cgi.c
 ===================================================================
---- src/mod_cgi.c      (.../tags/lighttpd-1.4.19)      (revision 2190)
-+++ src/mod_cgi.c      (.../branches/lighttpd-1.4.x)   (revision 2190)
+--- src/mod_cgi.c      (.../tags/lighttpd-1.4.19)      (revision 2199)
++++ src/mod_cgi.c      (.../branches/lighttpd-1.4.x)   (revision 2199)
 @@ -987,6 +987,8 @@
                        *c = '/';
                }
@@ -173,8 +173,8 @@ Index: src/mod_cgi.c
                                chunkqueue_remove_finished_chunks(cq);
 Index: src/mod_rewrite.c
 ===================================================================
---- src/mod_rewrite.c  (.../tags/lighttpd-1.4.19)      (revision 2190)
-+++ src/mod_rewrite.c  (.../branches/lighttpd-1.4.x)   (revision 2190)
+--- src/mod_rewrite.c  (.../tags/lighttpd-1.4.19)      (revision 2199)
++++ src/mod_rewrite.c  (.../branches/lighttpd-1.4.x)   (revision 2199)
 @@ -385,8 +385,7 @@
  
                        start = 0; end = pattern_len;
@@ -199,8 +199,8 @@ Index: src/mod_rewrite.c
                                                        buffer_append_string(con->request.uri, list[num]);
 Index: src/lempar.c
 ===================================================================
---- src/lempar.c       (.../tags/lighttpd-1.4.19)      (revision 2190)
-+++ src/lempar.c       (.../branches/lighttpd-1.4.x)   (revision 2190)
+--- src/lempar.c       (.../tags/lighttpd-1.4.19)      (revision 2199)
++++ src/lempar.c       (.../branches/lighttpd-1.4.x)   (revision 2199)
 @@ -210,7 +210,7 @@
  */
  const char *ParseTokenName(int tokenType){
@@ -248,8 +248,8 @@ Index: src/lempar.c
  %%
 Index: src/connections.c
 ===================================================================
---- src/connections.c  (.../tags/lighttpd-1.4.19)      (revision 2190)
-+++ src/connections.c  (.../branches/lighttpd-1.4.x)   (revision 2190)
+--- src/connections.c  (.../tags/lighttpd-1.4.19)      (revision 2199)
++++ src/connections.c  (.../branches/lighttpd-1.4.x)   (revision 2199)
 @@ -199,6 +199,7 @@
  
        /* don't resize the buffer if we were in SSL_ERROR_WANT_* */
@@ -423,8 +423,8 @@ Index: src/connections.c
                        switch(con->mode) {
 Index: src/configfile.c
 ===================================================================
---- src/configfile.c   (.../tags/lighttpd-1.4.19)      (revision 2190)
-+++ src/configfile.c   (.../branches/lighttpd-1.4.x)   (revision 2190)
+--- src/configfile.c   (.../tags/lighttpd-1.4.19)      (revision 2199)
++++ src/configfile.c   (.../branches/lighttpd-1.4.x)   (revision 2199)
 @@ -7,6 +7,7 @@
  #include <string.h>
  #include <stdio.h>
@@ -517,8 +517,8 @@ Index: src/configfile.c
  
 Index: src/lemon.c
 ===================================================================
---- src/lemon.c        (.../tags/lighttpd-1.4.19)      (revision 2190)
-+++ src/lemon.c        (.../branches/lighttpd-1.4.x)   (revision 2190)
+--- src/lemon.c        (.../tags/lighttpd-1.4.19)      (revision 2199)
++++ src/lemon.c        (.../branches/lighttpd-1.4.x)   (revision 2199)
 @@ -12,6 +12,19 @@
  #include <ctype.h>
  #include <stdlib.h>
@@ -601,8 +601,8 @@ Index: src/lemon.c
    size_t filesize;
 Index: src/mod_scgi.c
 ===================================================================
---- src/mod_scgi.c     (.../tags/lighttpd-1.4.19)      (revision 2190)
-+++ src/mod_scgi.c     (.../branches/lighttpd-1.4.x)   (revision 2190)
+--- src/mod_scgi.c     (.../tags/lighttpd-1.4.19)      (revision 2199)
++++ src/mod_scgi.c     (.../branches/lighttpd-1.4.x)   (revision 2199)
 @@ -202,6 +202,15 @@
         *
         */
@@ -875,8 +875,8 @@ Index: src/mod_scgi.c
  
 Index: src/lighttpd-angel.c
 ===================================================================
---- src/lighttpd-angel.c       (.../tags/lighttpd-1.4.19)      (revision 2190)
-+++ src/lighttpd-angel.c       (.../branches/lighttpd-1.4.x)   (revision 2190)
+--- src/lighttpd-angel.c       (.../tags/lighttpd-1.4.19)      (revision 2199)
++++ src/lighttpd-angel.c       (.../branches/lighttpd-1.4.x)   (revision 2199)
 @@ -28,9 +28,12 @@
  static volatile sig_atomic_t graceful_restart = 0;
  static volatile pid_t pid = -1;
@@ -901,8 +901,8 @@ Index: src/lighttpd-angel.c
         */
 Index: src/mod_rrdtool.c
 ===================================================================
---- src/mod_rrdtool.c  (.../tags/lighttpd-1.4.19)      (revision 2190)
-+++ src/mod_rrdtool.c  (.../branches/lighttpd-1.4.x)   (revision 2190)
+--- src/mod_rrdtool.c  (.../tags/lighttpd-1.4.19)      (revision 2199)
++++ src/mod_rrdtool.c  (.../branches/lighttpd-1.4.x)   (revision 2199)
 @@ -148,6 +148,8 @@
                args[i++] = dash;
                args[i++] = NULL;
@@ -923,8 +923,8 @@ Index: src/mod_rrdtool.c
                SEGFAULT();
 Index: src/response.c
 ===================================================================
---- src/response.c     (.../tags/lighttpd-1.4.19)      (revision 2190)
-+++ src/response.c     (.../branches/lighttpd-1.4.x)   (revision 2190)
+--- src/response.c     (.../tags/lighttpd-1.4.19)      (revision 2199)
++++ src/response.c     (.../branches/lighttpd-1.4.x)   (revision 2199)
 @@ -101,7 +101,7 @@
        if (!have_server) {
                if (buffer_is_empty(con->conf.server_tag)) {
@@ -945,8 +945,8 @@ Index: src/response.c
                        log_error_write(srv, __FILE__, __LINE__,  "s",  "run condition");
 Index: src/plugin.c
 ===================================================================
---- src/plugin.c       (.../tags/lighttpd-1.4.19)      (revision 2190)
-+++ src/plugin.c       (.../branches/lighttpd-1.4.x)   (revision 2190)
+--- src/plugin.c       (.../tags/lighttpd-1.4.19)      (revision 2199)
++++ src/plugin.c       (.../branches/lighttpd-1.4.x)   (revision 2199)
 @@ -197,7 +197,7 @@
  
  #else
@@ -958,8 +958,8 @@ Index: src/plugin.c
  #endif
 Index: src/SConscript
 ===================================================================
---- src/SConscript     (.../tags/lighttpd-1.4.19)      (revision 2190)
-+++ src/SConscript     (.../branches/lighttpd-1.4.x)   (revision 2190)
+--- src/SConscript     (.../tags/lighttpd-1.4.19)      (revision 2199)
++++ src/SConscript     (.../branches/lighttpd-1.4.x)   (revision 2199)
 @@ -43,6 +43,7 @@
        'mod_cgi' : { 'src' : [ 'mod_cgi.c' ] },
        'mod_fastcgi' : { 'src' : [ 'mod_fastcgi.c' ] },
@@ -970,8 +970,8 @@ Index: src/SConscript
        'mod_indexfile' : { 'src' : [ 'mod_indexfile.c' ] },
 Index: src/mod_extforward.c
 ===================================================================
---- src/mod_extforward.c       (.../tags/lighttpd-1.4.19)      (revision 2190)
-+++ src/mod_extforward.c       (.../branches/lighttpd-1.4.x)   (revision 2190)
+--- src/mod_extforward.c       (.../tags/lighttpd-1.4.19)      (revision 2199)
++++ src/mod_extforward.c       (.../branches/lighttpd-1.4.x)   (revision 2199)
 @@ -281,8 +281,9 @@
  static const char *last_not_in_array(array *a, plugin_data *p)
  {
@@ -985,8 +985,8 @@ Index: src/mod_extforward.c
  
 Index: src/Makefile.am
 ===================================================================
---- src/Makefile.am    (.../tags/lighttpd-1.4.19)      (revision 2190)
-+++ src/Makefile.am    (.../branches/lighttpd-1.4.x)   (revision 2190)
+--- src/Makefile.am    (.../tags/lighttpd-1.4.19)      (revision 2199)
++++ src/Makefile.am    (.../branches/lighttpd-1.4.x)   (revision 2199)
 @@ -16,20 +16,17 @@
  configparser.c configparser.h:
  mod_ssi_exprparser.c mod_ssi_exprparser.h:
@@ -1014,8 +1014,8 @@ Index: src/Makefile.am
        keyvalue.c chunk.c  \
 Index: src/network_openssl.c
 ===================================================================
---- src/network_openssl.c      (.../tags/lighttpd-1.4.19)      (revision 2190)
-+++ src/network_openssl.c      (.../branches/lighttpd-1.4.x)   (revision 2190)
+--- src/network_openssl.c      (.../tags/lighttpd-1.4.19)      (revision 2199)
++++ src/network_openssl.c      (.../branches/lighttpd-1.4.x)   (revision 2199)
 @@ -85,6 +85,7 @@
                         *
                         */
@@ -1034,8 +1034,8 @@ Index: src/network_openssl.c
  
 Index: src/mod_redirect.c
 ===================================================================
---- src/mod_redirect.c (.../tags/lighttpd-1.4.19)      (revision 2190)
-+++ src/mod_redirect.c (.../branches/lighttpd-1.4.x)   (revision 2190)
+--- src/mod_redirect.c (.../tags/lighttpd-1.4.19)      (revision 2199)
++++ src/mod_redirect.c (.../branches/lighttpd-1.4.x)   (revision 2199)
 @@ -215,8 +215,7 @@
  
                        start = 0; end = pattern_len;
@@ -1060,8 +1060,8 @@ Index: src/mod_redirect.c
                                                        buffer_append_string(p->location, list[num]);
 Index: src/mod_webdav.c
 ===================================================================
---- src/mod_webdav.c   (.../tags/lighttpd-1.4.19)      (revision 2190)
-+++ src/mod_webdav.c   (.../branches/lighttpd-1.4.x)   (revision 2190)
+--- src/mod_webdav.c   (.../tags/lighttpd-1.4.19)      (revision 2199)
++++ src/mod_webdav.c   (.../branches/lighttpd-1.4.x)   (revision 2199)
 @@ -570,6 +570,8 @@
                                /* */
                        }
@@ -1102,8 +1102,8 @@ Index: src/mod_webdav.c
        return has_lock;
 Index: src/md5.c
 ===================================================================
---- src/md5.c  (.../tags/lighttpd-1.4.19)      (revision 2190)
-+++ src/md5.c  (.../branches/lighttpd-1.4.x)   (revision 2190)
+--- src/md5.c  (.../tags/lighttpd-1.4.19)      (revision 2199)
++++ src/md5.c  (.../branches/lighttpd-1.4.x)   (revision 2199)
 @@ -52,9 +52,9 @@
  #define S43 15
  #define S44 21
@@ -1152,8 +1152,8 @@ Index: src/md5.c
    unsigned int i, j;
 Index: src/mod_compress.c
 ===================================================================
---- src/mod_compress.c (.../tags/lighttpd-1.4.19)      (revision 2190)
-+++ src/mod_compress.c (.../branches/lighttpd-1.4.x)   (revision 2190)
+--- src/mod_compress.c (.../tags/lighttpd-1.4.19)      (revision 2199)
++++ src/mod_compress.c (.../branches/lighttpd-1.4.x)   (revision 2199)
 @@ -102,7 +102,7 @@
        return HANDLER_GO_ON;
  }
@@ -1201,8 +1201,8 @@ Index: src/mod_compress.c
                                                s->compress_cache_dir, strerror(errno));
 Index: src/md5.h
 ===================================================================
---- src/md5.h  (.../tags/lighttpd-1.4.19)      (revision 2190)
-+++ src/md5.h  (.../branches/lighttpd-1.4.x)   (revision 2190)
+--- src/md5.h  (.../tags/lighttpd-1.4.19)      (revision 2199)
++++ src/md5.h  (.../branches/lighttpd-1.4.x)   (revision 2199)
 @@ -42,6 +42,6 @@
  } MD5_CTX;
  
@@ -1211,10 +1211,405 @@ Index: src/md5.h
 +void MD5_Update (MD5_CTX *, const void *, unsigned int);
  void MD5_Final (unsigned char [16], MD5_CTX *);
  
+Index: src/spawn-fcgi.c
+===================================================================
+--- src/spawn-fcgi.c   (.../tags/lighttpd-1.4.19)      (revision 2199)
++++ src/spawn-fcgi.c   (.../branches/lighttpd-1.4.x)   (revision 2199)
+@@ -37,9 +37,9 @@
+ #endif
+ #ifdef HAVE_SYS_UN_H
+-int fcgi_spawn_connection(char *appPath, char **appArgv, char *addr, unsigned short port, const char *unixsocket, int child_count, int pid_fd, int nofork) {
++int fcgi_spawn_connection(char *appPath, char **appArgv, char *addr, unsigned short port, const char *unixsocket, int fork_count, int child_count, int pid_fd, int nofork) {
+       int fcgi_fd;
+-      int socket_type, status;
++      int socket_type, status, rc = 0;
+       struct timeval tv = { 0, 100 * 1000 };
+       struct sockaddr_un fcgi_addr_un;
+@@ -48,9 +48,6 @@
+       socklen_t servlen;
+-      pid_t child;
+-      int val;
+-
+       if (child_count < 2) {
+               child_count = 5;
+       }
+@@ -74,25 +71,6 @@
+ #endif
+               socket_type = AF_UNIX;
+               fcgi_addr = (struct sockaddr *) &fcgi_addr_un;
+-
+-              /* check if some backend is listening on the socket
+-               * as if we delete the socket-file and rebind there will be no "socket already in use" error
+-               */
+-              if (-1 == (fcgi_fd = socket(socket_type, SOCK_STREAM, 0))) {
+-                      fprintf(stderr, "%s.%d\n",
+-                              __FILE__, __LINE__);
+-                      return -1;
+-              }
+-
+-              if (-1 != connect(fcgi_fd, fcgi_addr, servlen)) {
+-                      fprintf(stderr, "%s.%d: socket is already used, can't spawn\n",
+-                              __FILE__, __LINE__);
+-                      return -1;
+-              }
+-
+-              /* cleanup previous socket if it exists */
+-              unlink(unixsocket);
+-              close(fcgi_fd);
+       } else {
+               fcgi_addr_in.sin_family = AF_INET;
+                 if (addr != NULL) {
+@@ -107,133 +85,176 @@
+               fcgi_addr = (struct sockaddr *) &fcgi_addr_in;
+       }
+-      /* open socket */
+       if (-1 == (fcgi_fd = socket(socket_type, SOCK_STREAM, 0))) {
+               fprintf(stderr, "%s.%d\n",
+                       __FILE__, __LINE__);
+               return -1;
+       }
+-      val = 1;
+-      if (setsockopt(fcgi_fd, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val)) < 0) {
+-              fprintf(stderr, "%s.%d\n",
+-                      __FILE__, __LINE__);
+-              return -1;
+-      }
++      if (-1 == connect(fcgi_fd, fcgi_addr, servlen)) {
++              /* server is not up, spawn in  */
++              pid_t child;
++              int val;
+-      /* create socket */
+-      if (-1 == bind(fcgi_fd, fcgi_addr, servlen)) {
+-              fprintf(stderr, "%s.%d: bind failed: %s\n",
+-                      __FILE__, __LINE__,
+-                      strerror(errno));
+-              return -1;
+-      }
++              if (unixsocket) unlink(unixsocket);
+-      if (-1 == listen(fcgi_fd, 1024)) {
+-              fprintf(stderr, "%s.%d: fd = -1\n",
+-                      __FILE__, __LINE__);
+-              return -1;
+-      }
++              close(fcgi_fd);
+-      if (!nofork) {
+-              child = fork();
+-      } else {
+-              child = 0;
+-      }
++              /* reopen socket */
++              if (-1 == (fcgi_fd = socket(socket_type, SOCK_STREAM, 0))) {
++                      fprintf(stderr, "%s.%d\n",
++                              __FILE__, __LINE__);
++                      return -1;
++              }
+-      switch (child) {
+-      case 0: {
+-              char cgi_childs[64];
++              val = 1;
++              if (setsockopt(fcgi_fd, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val)) < 0) {
++                      fprintf(stderr, "%s.%d\n",
++                              __FILE__, __LINE__);
++                      return -1;
++              }
+-              int i = 0;
+-
+-              /* is safe as we limit to 256 childs */
+-              sprintf(cgi_childs, "PHP_FCGI_CHILDREN=%d", child_count);
+-
+-              if(fcgi_fd != FCGI_LISTENSOCK_FILENO) {
+-                      close(FCGI_LISTENSOCK_FILENO);
+-                      dup2(fcgi_fd, FCGI_LISTENSOCK_FILENO);
+-                      close(fcgi_fd);
++              /* create socket */
++              if (-1 == bind(fcgi_fd, fcgi_addr, servlen)) {
++                      fprintf(stderr, "%s.%d: bind failed: %s\n",
++                              __FILE__, __LINE__,
++                              strerror(errno));
++                      return -1;
+               }
+-              /* we don't need the client socket */
+-              for (i = 3; i < 256; i++) {
+-                      close(i);
++              if (-1 == listen(fcgi_fd, 1024)) {
++                      fprintf(stderr, "%s.%d: fd = -1\n",
++                              __FILE__, __LINE__);
++                      return -1;
+               }
+-              /* create environment */
++              while (fork_count-- > 0) {
+-              putenv(cgi_childs);
++                      if (!nofork) {
++                              child = fork();
++                      } else {
++                              child = 0;
++                      }
+-              /* fork and replace shell */
+-              if (appArgv) {
+-                      execv(appArgv[0], appArgv);
++                      switch (child) {
++                      case 0: {
++                              char cgi_childs[64];
++                              int max_fd = 0;
+-              } else {
+-                      char *b = malloc(strlen("exec ") + strlen(appPath) + 1);
+-                      strcpy(b, "exec ");
+-                      strcat(b, appPath);
++                              int i = 0;
+-                      /* exec the cgi */
+-                      execl("/bin/sh", "sh", "-c", b, (char *)NULL);
+-              }
++                              /* loose control terminal */
++                              setsid();
+-              exit(errno);
++                              /* is safe as we limit to 256 childs */
++                              sprintf(cgi_childs, "PHP_FCGI_CHILDREN=%d", child_count);
+-              break;
+-      }
+-      case -1:
+-              /* error */
+-              break;
+-      default:
+-              /* father */
++                              if(fcgi_fd != FCGI_LISTENSOCK_FILENO) {
++                                      close(FCGI_LISTENSOCK_FILENO);
++                                      dup2(fcgi_fd, FCGI_LISTENSOCK_FILENO);
++                                      close(fcgi_fd);
++                              }
+-              /* wait */
+-              select(0, NULL, NULL, NULL, &tv);
++                              max_fd = open("/dev/null", O_RDWR);
++                              close(STDERR_FILENO);
++                              dup2(max_fd, STDERR_FILENO);
++                              close(max_fd);
+-              switch (waitpid(child, &status, WNOHANG)) {
+-              case 0:
+-                      fprintf(stderr, "%s.%d: child spawned successfully: PID: %d\n",
+-                              __FILE__, __LINE__,
+-                              child);
++                              max_fd = open("/dev/null", O_RDWR);
++                              close(STDOUT_FILENO);
++                              dup2(max_fd, STDOUT_FILENO);
++                              close(max_fd);
+-                      /* write pid file */
+-                      if (pid_fd != -1) {
+-                              /* assume a 32bit pid_t */
+-                              char pidbuf[12];
++                              /* we don't need the client socket */
++                              for (i = 3; i < max_fd; i++) {
++                                      if (i != FCGI_LISTENSOCK_FILENO) close(i);
++                              }
+-                              snprintf(pidbuf, sizeof(pidbuf) - 1, "%d", child);
++                              /* create environment */
+-                              write(pid_fd, pidbuf, strlen(pidbuf));
+-                              close(pid_fd);
+-                              pid_fd = -1;
++                              putenv(cgi_childs);
++
++                              /* fork and replace shell */
++                              if (appArgv) {
++                                      execv(appArgv[0], appArgv);
++
++                              } else {
++                                      char *b = malloc(strlen("exec ") + strlen(appPath) + 1);
++                                      strcpy(b, "exec ");
++                                      strcat(b, appPath);
++
++                                      /* exec the cgi */
++                                      execl("/bin/sh", "sh", "-c", b, (char *)NULL);
++                              }
++
++                              exit(errno);
++
++                              break;
+                       }
++                      case -1:
++                              /* error */
++                              break;
++                      default:
++                              /* father */
+-                      break;
+-              case -1:
+-                      break;
+-              default:
+-                      if (WIFEXITED(status)) {
+-                              fprintf(stderr, "%s.%d: child exited with: %d, %s\n",
+-                                      __FILE__, __LINE__,
+-                                      WEXITSTATUS(status), strerror(WEXITSTATUS(status)));
+-                      } else if (WIFSIGNALED(status)) {
+-                              fprintf(stderr, "%s.%d: child signaled: %d\n",
+-                                      __FILE__, __LINE__,
+-                                      WTERMSIG(status));
+-                      } else {
+-                              fprintf(stderr, "%s.%d: child died somehow: %d\n",
+-                                      __FILE__, __LINE__,
+-                                      status);
++                              /* wait */
++                              select(0, NULL, NULL, NULL, &tv);
++
++                              switch (waitpid(child, &status, WNOHANG)) {
++                              case 0:
++                                      fprintf(stdout, "%s.%d: child spawned successfully: PID: %d\n",
++                                              __FILE__, __LINE__,
++                                              child);
++
++                                      /* write pid file */
++                                      if (pid_fd != -1) {
++                                              /* assume a 32bit pid_t */
++                                              char pidbuf[12];
++
++                                              snprintf(pidbuf, sizeof(pidbuf) - 1, "%d", child);
++
++                                              write(pid_fd, pidbuf, strlen(pidbuf));
++                                              /* avoid eol for the last one */
++                                              if (fork_count != 0) {
++                                                      write(pid_fd, "\n", 1);
++                                              }
++                                      }
++
++                                      break;
++                              case -1:
++                                      break;
++                              default:
++                                      if (WIFEXITED(status)) {
++                                              fprintf(stderr, "%s.%d: child exited with: %d\n",
++                                                      __FILE__, __LINE__, WEXITSTATUS(status));
++                                              rc = WEXITSTATUS(status);
++                                      } else if (WIFSIGNALED(status)) {
++                                              fprintf(stderr, "%s.%d: child signaled: %d\n",
++                                                      __FILE__, __LINE__,
++                                                      WTERMSIG(status));
++                                              rc = 1;
++                                      } else {
++                                              fprintf(stderr, "%s.%d: child died somehow: %d\n",
++                                                      __FILE__, __LINE__,
++                                                      status);
++                                              rc = status;
++                                      }
++                              }
++
++                              break;
+                       }
+               }
+-
+-              break;
++              close(pid_fd);
++              pid_fd = -1;
++      } else {
++              fprintf(stderr, "%s.%d: socket is already used, can't spawn\n",
++                      __FILE__, __LINE__);
++              return -1;
+       }
+       close(fcgi_fd);
+-      return 0;
++      return rc;
+ }
+@@ -256,6 +277,7 @@
+ " -p <port>    bind to tcp-port\n" \
+ " -s <path>    bind to unix-domain socket\n" \
+ " -C <childs>  (PHP only) numbers of childs to spawn (default 5)\n" \
++" -F <childs>  numbers of childs to fork (default 1)\n" \
+ " -P <path>    name of PID-file for spawed process\n" \
+ " -n           no fork (for daemontools)\n" \
+ " -v           show version\n" \
+@@ -276,20 +298,21 @@
+       char **fcgi_app_argv = { NULL };
+       unsigned short port = 0;
+       int child_count = 5;
++      int fork_count = 1;
+       int i_am_root, o;
+       int pid_fd = -1;
+       int nofork = 0;
+       struct sockaddr_un un;
+-      const size_t sun_path_len = sizeof(un.sun_path);
+       i_am_root = (getuid() == 0);
+-      while(-1 != (o = getopt(argc, argv, "c:f:g:hna:p:u:vC:s:P:"))) {
++      while (-1 != (o = getopt(argc, argv, "c:f:g:hna:p:u:vC:F:s:P:"))) {
+               switch(o) {
+               case 'f': fcgi_app = optarg; break;
+               case 'a': addr = optarg;/* ip addr */ break;
+               case 'p': port = strtol(optarg, NULL, 10);/* port */ break;
+               case 'C': child_count = strtol(optarg, NULL, 10);/*  */ break;
++              case 'F': fork_count = strtol(optarg, NULL, 10);/*  */ break;
+               case 's': unixsocket = optarg; /* unix-domain socket */ break;
+               case 'c': if (i_am_root) { changeroot = optarg; }/* chroot() */ break;
+               case 'u': if (i_am_root) { username = optarg; } /* set user */ break;
+@@ -321,7 +344,7 @@
+               return -1;
+       }
+-      if (unixsocket && strlen(unixsocket) > sun_path_len - 1) {
++      if (unixsocket && strlen(unixsocket) > sizeof(un.sun_path) - 1) {
+               fprintf(stderr, "%s.%d: %s\n",
+                       __FILE__, __LINE__,
+                       "path of the unix socket is too long\n");
+@@ -416,18 +439,15 @@
+                                       "I will not set gid to 0\n");
+                               return -1;
+                       }
+-              }
+-              /*
+-               * Change group before chroot, when we have access
+-               * to /etc/group
+-               */
+-              if (groupname) {
++                      /* do the change before we do the chroot() */
+                       setgid(grp->gr_gid);
+-                      setgroups(0, NULL);
++                      setgroups(0, NULL); 
++
+                       if (username) {
+                               initgroups(username, grp->gr_gid);
+                       }
++
+               }
+               if (changeroot) {
+@@ -451,7 +471,7 @@
+               }
+       }
+-       return fcgi_spawn_connection(fcgi_app, fcgi_app_argv, addr, port, unixsocket, child_count, pid_fd, nofork);
++       return fcgi_spawn_connection(fcgi_app, fcgi_app_argv, addr, port, unixsocket, fork_count, child_count, pid_fd, nofork);
+ }
+ #else
+ int main() {
 Index: src/mod_auth.c
 ===================================================================
---- src/mod_auth.c     (.../tags/lighttpd-1.4.19)      (revision 2190)
-+++ src/mod_auth.c     (.../branches/lighttpd-1.4.x)   (revision 2190)
+--- src/mod_auth.c     (.../tags/lighttpd-1.4.19)      (revision 2199)
++++ src/mod_auth.c     (.../branches/lighttpd-1.4.x)   (revision 2199)
 @@ -519,85 +519,86 @@
  
  handler_t auth_ldap_init(server *srv, mod_auth_plugin_config *s) {
@@ -1360,8 +1755,8 @@ Index: src/mod_auth.c
  int mod_auth_plugin_init(plugin *p) {
 Index: src/mod_fastcgi.c
 ===================================================================
---- src/mod_fastcgi.c  (.../tags/lighttpd-1.4.19)      (revision 2190)
-+++ src/mod_fastcgi.c  (.../branches/lighttpd-1.4.x)   (revision 2190)
+--- src/mod_fastcgi.c  (.../tags/lighttpd-1.4.19)      (revision 2199)
++++ src/mod_fastcgi.c  (.../branches/lighttpd-1.4.x)   (revision 2199)
 @@ -236,6 +236,16 @@
        unsigned short break_scriptfilename_for_php;
  
@@ -1510,8 +1905,8 @@ Index: src/mod_fastcgi.c
        } else {
 Index: src/mod_accesslog.c
 ===================================================================
---- src/mod_accesslog.c        (.../tags/lighttpd-1.4.19)      (revision 2190)
-+++ src/mod_accesslog.c        (.../branches/lighttpd-1.4.x)   (revision 2190)
+--- src/mod_accesslog.c        (.../tags/lighttpd-1.4.19)      (revision 2199)
++++ src/mod_accesslog.c        (.../branches/lighttpd-1.4.x)   (revision 2199)
 @@ -473,7 +473,7 @@
                        continue;
                }
@@ -1567,8 +1962,8 @@ Index: src/mod_accesslog.c
                                buffer_append_string_buffer(b, con->uri.query);
 Index: src/server.c
 ===================================================================
---- src/server.c       (.../tags/lighttpd-1.4.19)      (revision 2190)
-+++ src/server.c       (.../branches/lighttpd-1.4.x)   (revision 2190)
+--- src/server.c       (.../tags/lighttpd-1.4.19)      (revision 2199)
++++ src/server.c       (.../branches/lighttpd-1.4.x)   (revision 2199)
 @@ -573,20 +573,9 @@
        }
  
@@ -1605,8 +2000,8 @@ Index: src/server.c
  
 Index: src/mod_dirlisting.c
 ===================================================================
---- src/mod_dirlisting.c       (.../tags/lighttpd-1.4.19)      (revision 2190)
-+++ src/mod_dirlisting.c       (.../branches/lighttpd-1.4.x)   (revision 2190)
+--- src/mod_dirlisting.c       (.../tags/lighttpd-1.4.19)      (revision 2199)
++++ src/mod_dirlisting.c       (.../branches/lighttpd-1.4.x)   (revision 2199)
 @@ -841,11 +841,11 @@
  
        /* Insert possible charset to Content-Type */
@@ -1623,8 +2018,8 @@ Index: src/mod_dirlisting.c
        con->file_finished = 1;
 Index: src/mod_magnet.c
 ===================================================================
---- src/mod_magnet.c   (.../tags/lighttpd-1.4.19)      (revision 2190)
-+++ src/mod_magnet.c   (.../branches/lighttpd-1.4.x)   (revision 2190)
+--- src/mod_magnet.c   (.../tags/lighttpd-1.4.19)      (revision 2199)
++++ src/mod_magnet.c   (.../branches/lighttpd-1.4.x)   (revision 2199)
 @@ -414,10 +414,16 @@
        case MAGNET_ENV_URI_AUTHORITY: dest = con->uri.authority; break;
        case MAGNET_ENV_URI_QUERY: dest = con->uri.query; break;
@@ -1661,8 +2056,8 @@ Index: src/mod_magnet.c
                        con->http_status = 500;
 Index: src/log.c
 ===================================================================
---- src/log.c  (.../tags/lighttpd-1.4.19)      (revision 2190)
-+++ src/log.c  (.../branches/lighttpd-1.4.x)   (revision 2190)
+--- src/log.c  (.../tags/lighttpd-1.4.19)      (revision 2199)
++++ src/log.c  (.../branches/lighttpd-1.4.x)   (revision 2199)
 @@ -31,6 +31,29 @@
  # define O_LARGEFILE 0
  #endif
@@ -1727,8 +2122,8 @@ Index: src/log.c
  
 Index: src/log.h
 ===================================================================
---- src/log.h  (.../tags/lighttpd-1.4.19)      (revision 2190)
-+++ src/log.h  (.../branches/lighttpd-1.4.x)   (revision 2190)
+--- src/log.h  (.../tags/lighttpd-1.4.19)      (revision 2199)
++++ src/log.h  (.../branches/lighttpd-1.4.x)   (revision 2199)
 @@ -3,6 +3,11 @@
  
  #include "server.h"
@@ -1749,8 +2144,8 @@ Name: svn:executable
 
 Index: tests/request.t
 ===================================================================
---- tests/request.t    (.../tags/lighttpd-1.4.19)      (revision 2190)
-+++ tests/request.t    (.../branches/lighttpd-1.4.x)   (revision 2190)
+--- tests/request.t    (.../tags/lighttpd-1.4.19)      (revision 2199)
++++ tests/request.t    (.../branches/lighttpd-1.4.x)   (revision 2199)
 @@ -101,7 +101,7 @@
  Expect: 100-continue
  EOF
@@ -1768,8 +2163,8 @@ Name: svn:executable
 
 Index: tests/mod-fastcgi.t
 ===================================================================
---- tests/mod-fastcgi.t        (.../tags/lighttpd-1.4.19)      (revision 2190)
-+++ tests/mod-fastcgi.t        (.../branches/lighttpd-1.4.x)   (revision 2190)
+--- tests/mod-fastcgi.t        (.../tags/lighttpd-1.4.19)      (revision 2199)
++++ tests/mod-fastcgi.t        (.../branches/lighttpd-1.4.x)   (revision 2199)
 @@ -65,7 +65,7 @@
  EOF
   );
@@ -1781,8 +2176,8 @@ Index: tests/mod-fastcgi.t
  GET /get-server-env.php/foo?env=PATH_INFO HTTP/1.0
 Index: tests/docroot/www/get-env.php
 ===================================================================
---- tests/docroot/www/get-env.php      (.../tags/lighttpd-1.4.19)      (revision 2190)
-+++ tests/docroot/www/get-env.php      (.../branches/lighttpd-1.4.x)   (revision 2190)
+--- tests/docroot/www/get-env.php      (.../tags/lighttpd-1.4.19)      (revision 2199)
++++ tests/docroot/www/get-env.php      (.../branches/lighttpd-1.4.x)   (revision 2199)
 @@ -1,3 +1,4 @@
  <?php
 -      print $_ENV[$_GET["env"]];
@@ -1797,8 +2192,8 @@ Name: svn:executable
 
 Index: doc/userdir.txt
 ===================================================================
---- doc/userdir.txt    (.../tags/lighttpd-1.4.19)      (revision 2190)
-+++ doc/userdir.txt    (.../branches/lighttpd-1.4.x)   (revision 2190)
+--- doc/userdir.txt    (.../tags/lighttpd-1.4.19)      (revision 2199)
++++ doc/userdir.txt    (.../branches/lighttpd-1.4.x)   (revision 2199)
 @@ -46,10 +46,10 @@
  Options
  =======
@@ -1814,8 +2209,8 @@ Index: doc/userdir.txt
      userdir.path = "public_html"
 Index: SConstruct
 ===================================================================
---- SConstruct (.../tags/lighttpd-1.4.19)      (revision 2190)
-+++ SConstruct (.../branches/lighttpd-1.4.x)   (revision 2190)
+--- SConstruct (.../tags/lighttpd-1.4.19)      (revision 2199)
++++ SConstruct (.../branches/lighttpd-1.4.x)   (revision 2199)
 @@ -5,7 +5,7 @@
  from stat import *
  
@@ -1827,8 +2222,8 @@ Index: SConstruct
        p = re.compile('[^A-Z0-9]')
 Index: Makefile.am
 ===================================================================
---- Makefile.am        (.../tags/lighttpd-1.4.19)      (revision 2190)
-+++ Makefile.am        (.../branches/lighttpd-1.4.x)   (revision 2190)
+--- Makefile.am        (.../tags/lighttpd-1.4.19)      (revision 2199)
++++ Makefile.am        (.../branches/lighttpd-1.4.x)   (revision 2199)
 @@ -1,3 +1,3 @@
  SUBDIRS=src doc tests cygwin openwrt
  
@@ -1836,9 +2231,9 @@ Index: Makefile.am
 +EXTRA_DIST=autogen.sh SConstruct
 Index: NEWS
 ===================================================================
---- NEWS       (.../tags/lighttpd-1.4.19)      (revision 2190)
-+++ NEWS       (.../branches/lighttpd-1.4.x)   (revision 2190)
-@@ -3,8 +3,31 @@
+--- NEWS       (.../tags/lighttpd-1.4.19)      (revision 2199)
++++ NEWS       (.../branches/lighttpd-1.4.x)   (revision 2199)
+@@ -3,8 +3,33 @@
  NEWS
  ====
  
@@ -1865,6 +2260,8 @@ Index: NEWS
 +  * Do not rely on PATH_MAX (POSIX does not require it) (#580)
 +  * Disable logging to access.log if filename is an empty string
 +  * Implement a clean way to open /dev/null and use it to close stdin/out/err in the needed places (#624)
++  * merge spawn-fcgi changes from trunk (from @2191)
++  * let spawn-fcgi propagate exit code from spawned fcgi application
 +
 +- 1.4.19 - 2008-03-10
 +
@@ -1873,6 +2270,16 @@ Index: NEWS
    * fixed initgroups() called after chroot (#1384)
 Index: .cvsignore
 ===================================================================
+--- .cvsignore (.../tags/lighttpd-1.4.19)      (revision 2199)
++++ .cvsignore (.../branches/lighttpd-1.4.x)   (revision 2199)
+@@ -3,7 +3,6 @@
+ configure
+ depcomp
+ config.*
+-lighttpd.spec
+ mkinstalldirs
+ distribute.sh
+ autom4te.cache
 
 Property changes on: .
 ___________________________________________________________________
This page took 0.093678 seconds and 4 git commands to generate.