PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » HTTP » HTTP_Request » Bug #526

Fail to call setTimeout() in Net_Socket leaves program hanging

Details

Submitted2004-01-06 06:08 UTC
Fromjleelim at hotmail dot com
Assignedavb
StatusClosed
PackageHTTP_Request
PHP Version4.2
OSRedhat 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))