From:             
Operating system: Gentoo x86_64
PHP version:      5.2.14
Package:          Sockets related
Bug Type:         Bug
Bug description:fread is blocking even with the use of stream_select

Description:
------------
Using PHP CLI

Gentoo 64 bit box

PHP version 5.2.14

clean compile

Dual AMD Opteron 2212 CPU



Something is blocking in the code, it seems to be fread. I am sure this is
not the expected result.



I greatly simplified the sample I included.



I can just put the socket/stream in non-blocking mode, but I would much
prefer to use the code as I designed it. 



I have considered just using the socket functions in php or just writing
the code in C.



Once in a great while it will resume after about thirty to sixty seconds.
In non-blocking mode I have no issues. This is a php cli script that
connects to another daemon running on the same machine, I am using this php
script to parse data to place in a sql database.

Test script:
---------------
$so...@fsockopen("localhost","7777",$errno,$errstr,3);

if (!$sock)

{ 

    echo "sock error".$crlf;

}



while(true)

{

    $read=array($sock);

    $write=NULL;

    $except=NULL;

    $stat...@stream_select($read,$write,$except,1);

    if ($status===false)

    {

        echo "select error".$crlf;

        exit();

    }

    if ($status>0)

    {

        $data =  @fread($sock,128);

        echo $data;

        $out .= $data;

    }

    

    usleep(10000);

}

Expected result:
----------------
The loop should run for eternity as expected.

Actual result:
--------------
The loop is blocked, I am presuming by fread due to a failure of the
expected behavior of stream_select.

-- 
Edit bug report at http://bugs.php.net/bug.php?id=52602&edit=1
-- 
Try a snapshot (PHP 5.2):            
http://bugs.php.net/fix.php?id=52602&r=trysnapshot52
Try a snapshot (PHP 5.3):            
http://bugs.php.net/fix.php?id=52602&r=trysnapshot53
Try a snapshot (trunk):              
http://bugs.php.net/fix.php?id=52602&r=trysnapshottrunk
Fixed in SVN:                        
http://bugs.php.net/fix.php?id=52602&r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=52602&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=52602&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=52602&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=52602&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=52602&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=52602&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=52602&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=52602&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=52602&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=52602&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=52602&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=52602&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=52602&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=52602&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=52602&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=52602&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=52602&r=mysqlcfg

Reply via email to