[Chameleon] Interference with PHP's Garbage Collection

Abe Gillespie abe.gillespie at gmail.com
Tue May 9 13:24:54 EDT 2006


I knew I'd forget something.  It's a Win2003 server.  I'll have a look
into the function when I get the time (hopefully this week).

-Abe

On 5/9/06, Julien-Samuel Lacroix <jlacroix at mapgears.com> wrote:
> Hi,
>
> Are you on Windows or Linux?
>
> Here's the garbage collection function. Do you see any problem in it?
> First thing can be to set bDebug to true  and the szDebugDir at the top
> of chameleon/htdocs/common/session/session.php
>
> Julien
>
> /**
>   * _gc Called by PHP session manager when a session is started or
>   * register (not all the time) depending og session.gc_probability
>   */
> function _gc($nMaxLifeTime)
> {
>     if ($GLOBALS["bDebug"])
>      {
>        debug_msg("_gc called");
>      }
>      if ($GLOBALS['gszGarbageColectionCallBackFunction'] != "")
>      {
>          if
> (function_exists($GLOBALS['gszGarbageColectionCallBackFunction']))
>              eval($GLOBALS['gszGarbageColectionCallBackFunction']);
>      }
>
>      if ( !(PHP_OS == "WINNT" || PHP_OS == "WIN32") )
>      {
>        @touch($GLOBALS['gszSessSavePath']."/deleteme",
> time()-$nMaxLifeTime*60);
>        system("find ".$GLOBALS['gszSessSavePath']." -name sess_* ! -newer ".
>               $GLOBALS['gszSessSavePath']."/deleteme -exec rm -rf {} \; ");
>
>        return true;
>      }
>
>      $bReturn = true;
>
>      if (!$hDir = @opendir($GLOBALS['gszSessSavePath']))
>      {
>          return false;
>      }
>
>      while($szFile = readdir($hDir))
>      {
>          if (!strstr($szFile,'sess_'))
>              continue;
>
>          if (strpos($szFile,'sess_') != 0)
>              continue;
>
>          $szSessionDir = $GLOBALS['gszSessSavePath']."/".$szFile;
>          $szSessionFile = $szSessionDir."/session_file";
>
>          if (!($mtime = @filemtime($szSessionFile)))
>          {
>              $bReturn=false;
>              continue;
>          }
>
>          if (time() > $mtime + $nMaxLifeTime)
>          {
>              $bReturn = (deleteDirectory($szSessionDir)) ? $bReturn : false;
>          }
>          closedir($hDir);
>
>          return $bReturn;
>      }
> }
>
>
>
> Abe Gillespie wrote:
> > I'm afraid I will have to do that myself.  I like to stick with
> > built-in (i.e. "supported") technology where I can.  I might not be
> > able to in this case.
> >
> > Thanks for the help though.  Anyone else wanna chime in?
> >
> > -Abe
> >
> > On 5/9/06, Bart van den Eijnden (OSGIS) <bartvde at xs4all.nl> wrote:
> >
> >> Abe,
> >>
> >> we use a shell script to clean out the files instead.
> >>
> >> Best regards,
> >> Bart
> >>
> >> Abe Gillespie wrote:
> >>
> >> > I'm trying to pin down a problem with PHP's session tmp directory
> >> > growing out of control.  The problem grabbed my attention when a
> >> > customer's server ran out of space.  At that point the session
> >> > directory was 13.5G!
> >> >
> >> > I set the probability of garbage collection to 100 / 100 ... or
> >> > "always collect."  This has not helped since I see files beyond the
> >> > default age of 1440 seconds.
> >> >
> >> > Anyone else experiencing this or have a clue what I'm missing?
> >> >
> >> > System:
> >> > The only PHP app is Chameleon.
> >> > Chameleon 2.2
> >> > Apache 2.0.54
> >> > PHP 4.4.0
> >> >
> >> > All php.ini settings are default as included with php.ini.recommended
> >> > except for:
> >> > session.gc_probability = 100
> >> > session.gc_divisor     = 100
> >> >
> >> > Help is greatly appreciated.
> >> > -Abe
> >> >
> >> > _______________________________________________
> >> > Chameleon mailing list
> >> > Chameleon at lists.maptools.org
> >> > http://lists.maptools.org/mailman/listinfo/chameleon
> >> >
> >> >
> >>
> >>
> >> --
> >> Bart van den Eijnden
> >> OSGIS, Open Source GIS
> >> http://www.osgis.nl
> >>
> >>
> >
> > _______________________________________________
> > Chameleon mailing list
> > Chameleon at lists.maptools.org
> > http://lists.maptools.org/mailman/listinfo/chameleon
>
> --
> Julien-Samuel Lacroix
> Mapgears
> http://www.mapgears.com/
>



More information about the Chameleon mailing list