dougm       02/02/28 19:30:04

  Modified:    src/modules/perl modperl_perl.c
  Log:
  trickery to prevent perl_destruct from freeing the environ array does
  not work in win32 service shutdown.  pull a different stunt to get the
  same effect, preventing the server from crashing.
  
  Revision  Changes    Path
  1.11      +18 -0     modperl-2.0/src/modules/perl/modperl_perl.c
  
  Index: modperl_perl.c
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_perl.c,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- modperl_perl.c    11 Dec 2001 04:43:36 -0000      1.10
  +++ modperl_perl.c    1 Mar 2002 03:30:03 -0000       1.11
  @@ -85,6 +85,7 @@
   
   void modperl_perl_destruct(PerlInterpreter *perl)
   {
  +    char **orig_environ = NULL;
       dTHXa(perl);
   
       PERL_SET_CONTEXT(perl);
  @@ -97,7 +98,20 @@
        * at least, not if modperl is doing things right
        * this is a bug in Perl.
        */
  +#   ifdef WIN32
  +    /*
  +     * PL_origenviron = environ; doesn't work under win32 service.
  +     * we pull a different stunt here that has the same effect of
  +     * tricking perl into _not_ freeing the real 'environ' array.
  +     * instead temporarily swap with a dummy array we malloc
  +     * here which is ok to let perl free.
  +     */
  +    orig_environ = environ;
  +    environ = safemalloc(2 * sizeof(char *));
  +    environ[0] = NULL;
  +#   else
       PL_origenviron = environ;
  +#   endif
   #endif
   
       if (PL_endav) {
  @@ -113,4 +127,8 @@
   #ifndef WIN32
       perl_free(perl);
   #endif
  +
  +    if (orig_environ) {
  +        environ = orig_environ;
  +    }
   }
  
  
  


Reply via email to