ID:               20863
 Updated by:       [EMAIL PROTECTED]
 Reported By:      [EMAIL PROTECTED]
 Status:           Feedback
 Bug Type:         Filesystem function related
 Operating System: SuSE 7.3 Pro
 PHP Version:      4CVS-2002-12-06 (stable)
 New Comment:

Could you please remove the @ from your script, which block error
message and set error repoting level to E_ALL.
Please include any warning messages in your reply.


Previous Comments:
------------------------------------------------------------------------

[2002-12-06 11:41:52] [EMAIL PROTECTED]

I also tried adding ini_set("max_execution_time", "180") to the script
and it changed nothing. Just to make sure it was not hitting this limit
too.

------------------------------------------------------------------------

[2002-12-06 11:38:07] [EMAIL PROTECTED]

I do not have this enabled. My configure line looks like so:

./configure --enable-ftp --with-ldap=/usr/local/openldap
--with-mysql=/usr --with-openssl=/usr/local/openssl

I thought for the memory_limit directive to take effect would mean I
would to have had to add --enable-momory-limit to the configuration.
Has this changed recently (i.e. >= 4.2.1)?

------------------------------------------------------------------------

[2002-12-06 11:06:46] [EMAIL PROTECTED]

Does your PHP have a memory limit?

------------------------------------------------------------------------

[2002-12-06 10:44:55] [EMAIL PROTECTED]

BTW, The files I am examining are all text.

------------------------------------------------------------------------

[2002-12-06 10:38:36] [EMAIL PROTECTED]

Here is my src:

--------------------
$files = array();
$dirs = array();

function getMD5OfFile($f)  {
  return md5_file($f);
  //return exec("md5sum ".$f." | awk '{print $1}'");
}

function getFiles($d)  {
  global $files, $dirs;
  clearstatcache();
        
  if($dir = @opendir($d))  {
    while(($file = @readdir($dir)) !== false)  {
      if(($file != ".") && ($file != ".."))  {
        if(is_dir($d."/".$file)) $dirs[] = $d."/".$file;
        elseif(is_file($d."/".$file) && (substr($file,0,1) != "."))
$files[] = $d."/".$file;
      }               
    }
  }
}

/** Get files for directories **/
getFiles("/home/webdev");
while(($dir = array_shift($dirs)) !== null)  {
  getFiles($dir);
}

/** Ouptut findings **/
while(($file = array_shift($files)) !== null)  {
  echo $file.": ". getMD5FromFile($file) ."\n";
}

------------------

I first tried this with v4.2.1. What I am trying to do is get the MD5
for every file within the filesystem. Unfortunately this code freezes
after about 20 or so files (md5_file() or exec() returns ok until
then). If I uncomment the exec() return and comment the md5_file()
return, the script hangs at exactly the same spot. If comment both out
and run the script without md5'ing any files, I get a listing of all
files (no problem). 

I have also tried replacing the md5_file() code with one that was
listed here http://www.php.net/manual/en/function.md5-file.php that
will read the file into a variable and do a md5() on that var.
Unfortunately I got a FATAL: emalloc() error using that method. 

Finally, I tried getting the upgrading to v4.3.0-dev (latest snapshot
from snaps) and got the same results.

I cannot figure out why this hangs and does not bomb out. I think it
has something to do with maybe a cache of some sort or the memory
buffers are filling up. Maybe even something to with how I am
traversing the array of directories? But then, why would it work
without the md5 cals? I do not know, but I thought I would post it here
and see what you guys think. TIA.


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=20863&edit=1

Reply via email to