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 » Networking » Net_Server » Bug #3991

Fork.php doesn't work in conjunction with pcntl_alarm

Details

Request #3991Fork.php doesn't work in conjunction with pcntl_alarm
Submitted2005-03-29 11:53 UTC
Fromdavid at inspiredthinking dot co dot uk
Assignedcweiske
StatusClosed
PackageNet_Server
PHP Version5.0.3
OSFC1
Roadmaps(Not assigned)

Comments

[2005-03-29 11:53 UTC] david at inspiredthinking dot co dot uk

Description:
------------
When using pcntl_alarm and the Fork driver - the blocked socket is interrupted - and the Fork Driver think's there's a socket error.
An update for the serviceRequest function attached

Reproduce code:
---------------
function serviceRequest()
{
while( true )
{
$readFDs = array( $this->clientFD[0] );

// block and wait for data
$ready = @socket_select($readFDs, $this->null, $this->null, null);

if ($ready === false && socket_last_error($this->clientFD[0])!==0)
{
$this->_sendDebugMessage("socket_select() failed.");
$this->shutdown();
}

if (in_array($this->clientFD[0], $readFDs) && (!$ready===false))
{
$data = $this->readFromSocket();

// empty data => connection was closed
if ($data === false)
{
$this->_sendDebugMessage("Connection closed by peer");
$this->closeConnection();
}
else
{
$this->_sendDebugMessage("Received ".trim($data)." from ".$this->_getDebugInfo());

if (method_exists($this->callbackObj, "onReceiveData")) {
$this->callbackObj->onReceiveData(0, $data);
}
}
}
}
}

Expected result:
----------------
Socket operation should continue unless socket_last_error indicates there was an error.

Actual result:
--------------
The client connection is terminated.