diff options
author | jan <jan@152afb58-edef-0310-8abb-c4023f1b3aa9> | 2005-03-02 13:49:08 +0000 |
---|---|---|
committer | jan <jan@152afb58-edef-0310-8abb-c4023f1b3aa9> | 2005-03-02 13:49:08 +0000 |
commit | 05a6876754196b967d06517da723e9a2552974cc (patch) | |
tree | 2af2c154e1005b7c9c5b91e61ca6ed498db10872 | |
parent | 57dae937cfcc877de7ede65f7cf718383dee36a7 (diff) | |
download | lighttpd-05a6876754196b967d06517da723e9a2552974cc.tar.gz |
fixed handling of dead fastcgi processes if deamonized
fixed handling of dead fastcgi process which sent their SIGCLD to
initd and not to lighttpd. Moving the daemonize before starting
the fastcgi procs fixes this.
git-svn-id: svn://svn.lighttpd.net/lighttpd/trunk@74 152afb58-edef-0310-8abb-c4023f1b3aa9
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | NEWS | 2 | ||||
-rw-r--r-- | src/server.c | 31 | ||||
-rw-r--r-- | tests/fastcgi-auth.conf | 7 | ||||
-rw-r--r-- | tests/fastcgi-responder.conf | 2 | ||||
-rwxr-xr-x | tests/mod-fastcgi.t | 22 |
6 files changed, 49 insertions, 22 deletions
@@ -38,6 +38,13 @@ Feature Requests: - same config option twice -> aaa, aaa - remove default port from Host: +02.03.2005 14:47 - 1.3.12 +- mod_fastcgi + + fixed handling of dead fastcgi process which sent their SIGCLD to + initd and not to lighttpd. Moving the daemonize before starting + the fastcgi procs fixes this. + 01.03.2005 23:59 - irix @@ -12,6 +12,8 @@ NEWS * fixed segfault in debug-code * fixed mod_expire if modification-timestamps are used * fixed segfault on duplication Host-headers + * fixed endless loop in mod_fastcgi + * fixed handling of dead fastcgi-processes - 1.3.11 - 2005-02-20 diff --git a/src/server.c b/src/server.c index 8692437a..3c8e199f 100644 --- a/src/server.c +++ b/src/server.c @@ -71,6 +71,7 @@ static void sigaction_handler(int sig, siginfo_t *si, void *context) { case SIGTERM: srv_shutdown = 1; break; case SIGALRM: handle_sig_alarm = 1; break; case SIGHUP: handle_sig_hup = 1; break; + case SIGCLD: break; } } #elif defined(HAVE_SIGNAL) || defined(HAVE_SIGACTION) @@ -79,6 +80,7 @@ static void signal_handler(int sig) { case SIGTERM: srv_shutdown = 1; break; case SIGALRM: handle_sig_alarm = 1; break; case SIGHUP: handle_sig_hup = 1; break; + case SIGCLD: break; } } #endif @@ -595,6 +597,20 @@ int main (int argc, char **argv) { return -1; } + +#ifdef HAVE_FORK + /* network is up, let's deamonize ourself */ + if (srv->srvconf.dont_daemonize == 0) daemonize(); +#endif + + /* write pid file */ + if (pid_fd != -1) { + buffer_copy_long(srv->tmp_buf, getpid()); + buffer_append_string(srv->tmp_buf, "\n"); + write(pid_fd, srv->tmp_buf->ptr, srv->tmp_buf->used - 1); + close(pid_fd); + pid_fd = -1; + } if (HANDLER_GO_ON != plugins_call_set_defaults(srv)) { log_error_write(srv, __FILE__, __LINE__, "s", "Configuration of plugins failed. Going down."); @@ -628,19 +644,6 @@ int main (int argc, char **argv) { return -1; } -#ifdef HAVE_FORK - /* network is up, let's deamonize ourself */ - if (srv->srvconf.dont_daemonize == 0) daemonize(); -#endif - - /* write pid file */ - if (pid_fd != -1) { - buffer_copy_long(srv->tmp_buf, getpid()); - buffer_append_string(srv->tmp_buf, "\n"); - write(pid_fd, srv->tmp_buf->ptr, srv->tmp_buf->used - 1); - close(pid_fd); - pid_fd = -1; - } if (-1 == log_error_open(srv)) { log_error_write(srv, __FILE__, __LINE__, "s", @@ -683,6 +686,7 @@ int main (int argc, char **argv) { sigaction(SIGTERM, &act, NULL); sigaction(SIGHUP, &act, NULL); sigaction(SIGALRM, &act, NULL); + sigaction(SIGCLD, &act, NULL); #elif defined(HAVE_SIGNAL) /* ignore the SIGPIPE from sendfile() */ @@ -691,6 +695,7 @@ int main (int argc, char **argv) { signal(SIGALRM, signal_handler); signal(SIGTERM, signal_handler); signal(SIGHUP, signal_handler); + signal(SIGCLD, signal_handler); #endif #ifdef USE_ALARM diff --git a/tests/fastcgi-auth.conf b/tests/fastcgi-auth.conf index 2b7f73ff..f8875706 100644 --- a/tests/fastcgi-auth.conf +++ b/tests/fastcgi-auth.conf @@ -87,16 +87,11 @@ fastcgi.server = ( "/" => ( "grisu" => ( "host" => "192.168.0.2", "port" => 1027, - "bin-path" => "./fcgi-auth", + "bin-path" => "@SRCDIR@/fcgi-auth", "mode" => "authorizer", "docroot" => "/tmp/lighttpd/servers/www.example.org/pages/", ) -# "ulf" => ( -# "host" => "192.168.2.41", -# "docroot" => "/home/jan/servers/", -# "port" => 1026 -# ) ) ) diff --git a/tests/fastcgi-responder.conf b/tests/fastcgi-responder.conf index f5a82d11..b48bd960 100644 --- a/tests/fastcgi-responder.conf +++ b/tests/fastcgi-responder.conf @@ -90,7 +90,7 @@ fastcgi.server = ( ".fcgi" => ( "grisu" => ( "host" => "192.168.0.2", "port" => 1028, - "bin-path" => "./fcgi-responder", + "bin-path" => "@SRCDIR@/fcgi-responder", "check-local" => "disable", "max-procs" => 1, "min-procs" => 1 diff --git a/tests/mod-fastcgi.t b/tests/mod-fastcgi.t index a9b6fcd3..0a342282 100755 --- a/tests/mod-fastcgi.t +++ b/tests/mod-fastcgi.t @@ -2,7 +2,7 @@ use strict; use IO::Socket; -use Test::More tests => 38; +use Test::More tests => 39; my $basedir = (defined $ENV{'top_builddir'} ? $ENV{'top_builddir'} : '..'); my $srcdir = (defined $ENV{'srcdir'} ? $ENV{'srcdir'} : '.'); @@ -44,9 +44,18 @@ sub start_proc { # kill old proc if necessary stop_proc; + # pre-process configfile if necessary + # + + my $pwd = `pwd`; + chomp($pwd); + unlink("/tmp/cfg.file"); + system("cat ".$srcdir."/".$configfile.' | perl -pe "s#\@SRCDIR\@#'.$pwd.'/'.$basedir.'/tests/#" > /tmp/cfg.file'); + unlink($pidfile); - system($lighttpd_path." -f ".$srcdir."/".$configfile); + system($lighttpd_path." -f /tmp/cfg.file"); + unlink("/tmp/cfg.file"); if (-e $pidfile) { return 0; } else { @@ -407,6 +416,15 @@ EOF ok(handle_http == 0, 'killing fastcgi and wait for restart'); @request = ( <<EOF +GET /index.fcgi?die-at-end HTTP/1.0 +Host: www.example.org +EOF + ); +@response = ( { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => 'test123' } ); +ok(handle_http == 0, 'killing fastcgi and wait for restart'); + + +@request = ( <<EOF GET /index.fcgi?crlf HTTP/1.0 Host: www.example.org EOF |