Hi!

Trying to use mod_perl for a perl module to load a bunch of data on
server startup and writing possible changes back to disk on server
shutdown leads me to strange behaviour in the END { } block: The END
block is aborted, before all checking and writing is done. Therefore
the files on disk are not consistent (partly written, not in sync
etc.).

Works fine under mod_cgi - but new reading and writing at every
request is of cause NOT, what we want.

I could isolate and reproduce it:

Nothing defined for mod_perl in httpd.conf except:

PerlRequire     /home/ernest/lib/start-up.pl

The startup.pl:
---------------
>--snip--
#!/usr/bin/perl -w

use strict;

# extend @INC if needed
use lib qw ( /home/ernest/lib );

# make sure we are in a sane environment.
$ENV{GATEWAY_INTERFACE} =~ /^CGI-Perl/
        or die "GATEWAY_INTERFACE not Perl!";

# for things in the "/perl" URL
use Apache::Registry;

#load perl modules of your choice here
#this code is interpreted *once* when the server starts
use Apache::Status;

# tell me more about warnings
use Carp ();
$SIG{__WARN__} = \&Carp::cluck;


use MYMOD ();

1;
>--snip--

Module MYMOD:
-------------
>--snip--
#
#       This Module simulates a lengthy END block...
#
package MYMOD;

use strict;
use English;

#       SUBS

sub debug_log {
        print STDERR '[', scalar ( localtime ), '] [debug] child=', $PID, ' ', 
__PACKAGE__, @_, "\n";
}

#
#       time consuming cleanup...
#
END {
        debug_log ( '::END start' );
        my $m = 60;             #       sec
        my $i = $m;
        while ( $i > 0 ) {
                debug_log ( '::END ', $m - $i, ' of ', $m, ' sec' );
                sleep 1;
                $i--;
        }
        debug_log ( '::END done' );
}

1;
__END__

>--snip--

Starting Apache with:

/usr/local/apache/bin/httpd -X -f /home/ernest/conf/httpd.conf

and killing with ^C gives the wanted result in the error.log:

[Mon Oct 16 19:36:08 2000] [info] created shared memory segment #12417
[Mon Oct 16 19:38:17 2000] [debug] child=1507 MYMOD::END start
[Mon Oct 16 19:38:17 2000] [debug] child=1507 MYMOD::END 0 of 60 sec
[Mon Oct 16 19:38:18 2000] [debug] child=1507 MYMOD::END 1 of 60 sec
[Mon Oct 16 19:38:19 2000] [debug] child=1507 MYMOD::END 2 of 60 sec
[Mon Oct 16 19:38:20 2000] [debug] child=1507 MYMOD::END 3 of 60 sec
...
[Mon Oct 16 19:39:15 2000] [debug] child=1507 MYMOD::END 58 of 60 sec
[Mon Oct 16 19:39:16 2000] [debug] child=1507 MYMOD::END 59 of 60 sec
[Mon Oct 16 19:39:17 2000] [debug] child=1507 MYMOD::END done

Same with mod_cgi using a little cgi-skript just to load the module.


Starting Apache with:

/usr/local/apache/bin/httpd -f /home/ernest/conf/httpd.conf

starts the wanted 20 Servers with the shared module.

Shutting down with a little shell script containing:

        PID=`cat $PIDFILE`
        kill -15 $PID

shows the abortion in the error.log:

[Mon Oct 16 18:10:40 2000] [info] created shared memory segment #12289
[Mon Oct 16 18:10:40 2000] [notice] Apache/1.3.12 (Unix) mod_perl/1.24 PHP/4.0.2 
FrontPage/4.0.4.3 mod_ssl/2.6.5 OpenSSL/0.9.5a configured -- resuming normal operations
[Mon Oct 16 18:10:40 2000] [info] Server built: Sep 22 2000 19:19:57
[Mon Oct 16 18:11:30 2000] [debug] child=32700 MYMOD::END start
[Mon Oct 16 18:11:30 2000] [debug] child=32700 MYMOD::END 0 of 60 sec
[Mon Oct 16 18:11:30 2000] [debug] child=32699 MYMOD::END start
[Mon Oct 16 18:11:30 2000] [debug] child=32699 MYMOD::END 0 of 60 sec
... 40 lines ...
[Mon Oct 16 18:11:31 2000] [debug] child=32700 MYMOD::END 1 of 60 sec
[Mon Oct 16 18:11:31 2000] [debug] child=32698 MYMOD::END 1 of 60 sec
[Mon Oct 16 18:11:31 2000] [debug] child=32699 MYMOD::END 1 of 60 sec
... 20 lines ...
[Mon Oct 16 18:11:32 2000] [warn] child process 32681 still did not exit, sending a 
SIGTERM
[Mon Oct 16 18:11:32 2000] [warn] child process 32682 still did not exit, sending a 
SIGTERM
... 20 lines ...
[Mon Oct 16 18:11:32 2000] [debug] child=32700 MYMOD::END 2 of 60 sec
... 80 lines ...
[Mon Oct 16 18:11:35 2000] [debug] child=32682 MYMOD::END 5 of 60 sec
[Mon Oct 16 18:11:36 2000] [error] child process 32681 still did not exit, sending a 
SIGKILL
[Mon Oct 16 18:11:36 2000] [error] child process 32682 still did not exit, sending a 
SIGKILL
... 20 lines ...
[Mon Oct 16 18:11:36 2000] [info] removed PID file /home/ernest/logs/httpd.pid 
(pid=32679)
[Mon Oct 16 18:11:36 2000] [notice] caught SIGTERM, shutting down


Additional info:

perl -V
-------
Summary of my perl5 (5.0 patchlevel 5 subversion 3) configuration:
  Platform:
    osname=linux, osvers=2.2.5-22smp, archname=i386-linux
    uname='linux porky.devel.redhat.com 2.2.5-22smp #1 smp wed jun 2 09:11:51 edt 1999 
i686 unknown '
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef useperlio=undef d_sfio=undef
  Compiler:
    cc='cc', optimize='-O2 -m486 -fno-strength-reduce', gccversion=egcs-2.91.66 
19990314/Linux (egcs-1.1.2 release)
    cppflags='-Dbool=char -DHAS_BOOL -I/usr/local/include'
    ccflags ='-Dbool=char -DHAS_BOOL -I/usr/local/include'
    stdchar='char', d_stdstdio=undef, usevfork=false
    intsize=4, longsize=4, ptrsize=4, doublesize=8
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    alignbytes=4, usemymalloc=n, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lnsl -ldl -lm -lc -lposix -lcrypt
    libc=, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
    cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'

Characteristics of this binary (from libperl):
  Built under linux
  Compiled at Feb  2 2000 15:35:58
  @INC:
    /usr/lib/perl5/5.00503/i386-linux
    /usr/lib/perl5/5.00503
    /usr/lib/perl5/site_perl/5.005/i386-linux
    /usr/lib/perl5/site_perl/5.005

/usr/local/apache/bin/httpd -V
------------------------------
Server version: Apache/1.3.12 (Unix)
Server built:   Sep 22 2000 19:19:57
Server's Module Magic Number: 19990320:7
Server compiled with....
 -D EAPI
 -D HAVE_MMAP
 -D HAVE_SHMGET
 -D USE_SHMGET_SCOREBOARD
 -D USE_MMAP_FILES
 -D USE_FCNTL_SERIALIZED_ACCEPT
 -D HTTPD_ROOT="/usr/local/apache"
 -D SUEXEC_BIN="/usr/local/apache/bin/suexec"
 -D DEFAULT_PIDLOG="logs/httpd.pid"
 -D DEFAULT_SCOREBOARD="logs/httpd.scoreboard"
 -D DEFAULT_LOCKFILE="logs/httpd.lock"
 -D DEFAULT_XFERLOG="logs/access_log"
 -D DEFAULT_ERRORLOG="logs/error_log"
 -D TYPES_CONFIG_FILE="conf/mime.types"
 -D SERVER_CONFIG_FILE="conf/httpd.conf"
 -D ACCESS_CONFIG_FILE="conf/access.conf"
 -D RESOURCE_CONFIG_FILE="conf/srm.conf"

/usr/local/apache/bin/httpd -l
------------------------------
Compiled-in modules:
  http_core.c
  mod_env.c
  mod_log_config.c
  mod_mime.c
  mod_negotiation.c
  mod_status.c
  mod_include.c
  mod_autoindex.c
  mod_dir.c
  mod_cgi.c
  mod_asis.c
  mod_imap.c
  mod_actions.c
  mod_userdir.c
  mod_alias.c
  mod_rewrite.c
  mod_access.c
  mod_auth.c
  mod_setenvif.c
  mod_ssl.c
  mod_frontpage.c
  mod_php4.c
  mod_perl.c
suexec: disabled; invalid wrapper /usr/local/apache/bin/suexec

Sorry for all that stuff, hope, it's usefull.

Now my questions:

Why is the END block called 20 times? I thought, the module was loaded
only once?

Is there a possibility to tell Apache/mod_perl to wait for the end of
the END block?

What have I to ask from my webmaster - recompile, flags, special
configuration?

I have root access via telnet for setting up httpd.conf, install Perl
Modules etc., but I'm not allowed to recompile Apache or Perl.

Please help.

[And please don't tell me to let him remove mod_frontpage ;-))]

Ernest




--
Yours sincerely
Mit freundlichen Grüßen

Ernest Lergon

                VIRTUALITAS
Artists online, Fine Arts online, Poets online
        http://www.virtualitas.com/

Reply via email to