ID:               26863
 Updated by:       [EMAIL PROTECTED]
 Reported By:      jim at bluedojo dot com
-Status:           Open
+Status:           Assigned
 Bug Type:         *Directory/Filesystem functions
-Operating System: Windows XP
+Operating System: *
-PHP Version:      4CVS-2004-01-10
+PHP Version:      4CVS, 5CVS
-Assigned To:      
+Assigned To:      wez
 New Comment:

Wez, AFAICT, the timeout is not used at all for http fopen wrapper.
(default_socket_timeout php.ini option at least)



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

[2004-01-14 18:04:09] jim at bluedojo dot com

I will try to answer the question the best I can.

I have written a spider in php that can index millions of pages.  Every
once in a while it will encounter a page that will not load up (which I
thought was due to fgets).  When I type this url in the location bar of
a browser, the page seems like it will load forever and nothing will
show up.

When I set stream_set_timeout($fd, 6) then once would expect that $fd
will time out in 6 seconds and exit the loop.  I believe that feof
would detect that the stream would time out:


if ($fd = @fopen($url,'rb')){
   stream_set_timeout($fd, 6);
   $html = '';
   while (!feof($fd)) {
      $html .= trim(fgets($fd));
   }
   fclose($fd);
}

To answer wez's question, I had to find a url that didn't work (that
took forever to load) in order to test that feof would exit due to the
timing out of the stream ($fd).

The url that I was using wasn't working for about one day.  Then it
started to load normally in a browser a day later so I couldn't use it
anymore as a test case for this problem.

Making the stream time out is important for my application because it
needs to move on to the next url or else it will loop forever.

Hope that helps.

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

[2004-01-12 22:08:56] jim at bluedojo dot com

I think removing feof() solved the problem.  I don't get any infinite
stalls anymore.  Thanks.

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

[2004-01-10 19:48:26] [EMAIL PROTECTED]

So the URL needs to return a failure code in order
to trigger the problem?
Please as specific as you can about it to help us figure
out whats happening.

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

[2004-01-10 18:06:17] jim at bluedojo dot com

The url is now working now so I cannot use it as a test case (it needs
to return false).  I will see if I can find a new url to test it with
the new code.

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

[2004-01-10 17:35:18] [EMAIL PROTECTED]

I suspect the problem to be with feof() rather than fgets().

try this:

do {
   $line = fgets($fp);
   if ($line === false)
      break;
   $html .= trim($line);
} while(true);


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

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/26863

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

Reply via email to