mkoppanen/php-zmq — Issue #50: poll->remove bug
Author: dark9
Created: 2012-02-11 06:40:20+00:00
State: open

------------------------------------php script-----------------------------------------
bind('inproc://test');

$client=new ZMQSocket($context, ZMQ::SOCKET_XREQ);
$client->connect('inproc://test');

$client2=new ZMQSocket($context, ZMQ::SOCKET_XREQ);
$client2->connect('inproc://test');

$poll=new ZMQPoll();
$poll->add($server, ZMQ::POLL_IN);
$poll->add($client, ZMQ::POLL_IN);
$poll->add($client2, ZMQ::POLL_IN);

$readable = array();
$writable = array();

for($i=0;$i<20;$i++)
{
if($i===10)
{
$result=$poll->remove($client2);

if($result!==true)
{
print_r($poll->getLastErrors());
}
}

if($i%2)
{
$client->send('client1 '.$i);
}
else
{
$client2->send('client2 '.$i);
}

$event=$poll->poll($readable, $writable, 1);

if(!$event)
{
continue;
}

foreach ($readable as $socket)
{
$msg=$socket->recvMulti();

if($socket===$server)
{
echo 'client to server msg:'.print_r($msg[1], true).PHP_EOL;
}
else
{
echo 'server to client msg:'.print_r($msg[1], true).PHP_EOL;
}
}
}
?>
------------------------------------php script-----------------------------------------

------------------------------------php result-----------------------------------------
client to server msg:client2 0
client to server msg:client1 1
client to server msg:client2 2
client to server msg:client1 3
client to server msg:client2 4
client to server msg:client1 5
client to server msg:client2 6
client to server msg:client1 7
client to server msg:client2 8
client to server msg:client1 9
------------------------------------php result-----------------------------------------

------------------------------------bug description-----------------------------------------
$result=$poll->remove($client2);
only remove $client2, but $client same remove ?
look like if remove one, then clear all poll list.
------------------------------------bug description-----------------------------------------

------------------------------------php info-----------------------------------------
PHP Version => 5.3.10

System => Darwin localhost 11.2.0 Darwin Kernel Version 11.2.0: Tue Aug 9 20:54:00 PDT 2011; root:xnu-1699.24.8~1/RELEASE_X86_64 x86_64
Build Date => Feb 10 2012 14:47:34
Configure Command => './configure' '--prefix=/usr' '--disable-all' '--enable-cli' '--with-curl' '--with-zmq' '--enable-json' '--enable-memcached' '--disable-memcached-session' '--disable-cgi' '--with-rune' '--disable-ipv6' '--with-zlib-dir=/opt/local'
Server API => Command Line Interface
------------------------------------php info-----------------------------------------

------------------------------------php-zmq info-----------------------------------------
mkoppanen-php-zmq-1.0.2-2-g2d1fb76.zip
------------------------------------php-zmq info-----------------------------------------