respect max_session_size of -1 correctly (no limit) while reading session files

This commit is contained in:
Christian Binder 2010-11-17 16:50:12 +00:00
parent 1e314fb59d
commit 94d28beb57

View File

@ -54,16 +54,20 @@ class egw_session_files
return $values; return $values;
} }
if (!($max_session_size = ini_get('memory_limit'))) $max_session_size = '16M'; if (!($max_session_size = ini_get('memory_limit'))) $max_session_size = '16M';
switch(strtoupper(substr($max_session_size,-1))) if($max_session_size > 0)
{ {
case 'M': $max_session_size *= 1024*1024; break; switch(strtoupper(substr($max_session_size,-1)))
case 'K': $max_session_size *= 1024; break; {
case 'M': $max_session_size *= 1024*1024; break;
case 'K': $max_session_size *= 1024; break;
}
$max_session_size /= 4; // use at max 1/4 of the memory_limit to read sessions, the others get ignored
} }
$max_session_size /= 4; // use at max 1/4 of the memory_limit to read sessions, the others get ignored
while (($file = readdir($dir))) while (($file = readdir($dir)))
{ {
if ($file{0} == '.' || filesize($path.'/'.$file) >= $max_session_size) continue; if ($file{0} == '.') continue;
if ($max_session_size > 0 && filesize($path.'/'.$file) >= $max_session_size) continue;
if (substr($file,0,5) != 'sess_' || $session_cache[$file] === false) if (substr($file,0,5) != 'sess_' || $session_cache[$file] === false)
{ {