Home » HTTP » HTTP_Request » Bug #526
Fail to call setTimeout() in Net_Socket leaves program hanging
Details
| Submitted | 2004-01-06 06:08 UTC |
|---|---|
| From | jleelim at hotmail dot com |
| Assigned | avb |
| Status | Closed |
| Package | HTTP_Request |
| PHP Version | 4.2 |
| OS | Redhat 9 |
| Roadmaps | (Not assigned) |
Comments
[2004-01-06 06:08 UTC] jleelim at hotmail dot com
Description:
------------
I'm using HTTP_Request and I notice that my process will hang when connecting to a site that is very slow (eg. http://www.dmoz.org). This happens repeatedly right at the same moment the site (dmoz.org) becomes slow.
I believe the problem is because HTTP_Request doesn't call the setTimeout(..) function in Net_Socket needed to ensure that transferring data doesn't stall forever. The setTimeout(..) function in Net_Socket ensures that the socket is initialized with a finite timeout by in turn calling set_socket_timeout(..).
Note this is different from the connection timeout, which is only set during socket creation.
[2004-01-06 06:12 UTC] jleelim at hotmail dot com
A few more tests indicate that the problem is during sending or receiving data, not connecting to the site. Clearly, the program is not given a chance to timeout during data transfer.
[2004-01-17 07:34 UTC] jleelim at hotmail dot com
I added the call to $this->_sock->setTimeout(20,0) and my Apache process no longer hangs. It's fixed at maximum 20 seconds but should be made adjustable.
$Id: Request.php,v 1.33 2003/10/26 10:28:28 avb Exp $
Below is the diff:
------------------
548a549
> OR PEAR::isError($err = $this->_sock->setTimeout(20, 0))