poll->remove bug #50

Closed
dark9 opened this Issue Feb 11, 2012 · 2 comments

Comments

Projects
None yet
2 participants

dark9 commented Feb 11, 2012

------------------------------------php file-----------------------------------------


<?php
$context=new ZMQContext(1, false);
$server=new ZMQSocket($context, ZMQ::SOCKET_XREP);
$server->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($client);
        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 file-----------------------------------------

------------------------------------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-----------------------------------------

mkoppanen closed this in 87d3e5c Feb 15, 2012

Owner

mkoppanen commented Feb 15, 2012

Should be fixed in master, thanks!

dark9 commented Feb 15, 2012

new bug for fix version ( 87d3e5c Fixes GH-50 )
same php file now 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
client to server msg:client2 10
client to server msg:client1 11
client to server msg:client2 12
client to server msg:client1 13
client to server msg:client2 14
client to server msg:client1 15
client to server msg:client2 16
client to server msg:client1 17
client to server msg:client2 18
client to server msg:client1 19

look this line $result=$poll->remove($client);
client1 still here ?
poll->remove method become invalid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment