Browse Source

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
svn/tags/release-1.3.12
Jan Kneschke 17 years ago
parent
commit
9a5cf4a2ed
  1. 7
      ChangeLog
  2. 2
      NEWS
  3. 31
      src/server.c
  4. 7
      tests/fastcgi-auth.conf
  5. 2
      tests/fastcgi-responder.conf
  6. 22
      tests/mod-fastcgi.t

7
ChangeLog

@ -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

2
NEWS

@ -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

31
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

7
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
# )
)
)

2
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

22
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 {
@ -406,6 +415,15 @@ 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?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

Loading…
Cancel
Save