ID:               42720
 User updated by:  Slig at free dot fr
 Reported By:      Slig at free dot fr
 Status:           Open
 Bug Type:         Streams related
-Operating System: linux
+Operating System: linux & windows
 PHP Version:      5CVS-2007-09-21 (snap)
 New Comment:

Notes:

- it the same on Windows (tested on 32 bits 5.2.0 and current 5.2.4)

- using stream_socket_recvfrom() instead of fread(), there is not the
timeout at the last read.


Previous Comments:
------------------------------------------------------------------------

[2007-09-21 00:01:57] Slig at free dot fr

Description:
------------
Seems to be on all 5.2, 6 snap, on 32 bits and 64 bits linux.

Note the delay of the last read : it make a 60s timeout while it should
not because datas are available to read. Reading data with a bigger
length value or setting a small timeout time on the stream show that the
data is available immediatly, this timeout shouyld not happen.

It seems to happen only to the last read, when all readable datas where
not read in one shot.


Reproduce code:
---------------
<?php
$handle = fsockopen('tcp://smtp',25);
//stream_set_timeout($handle,0,1);

while(!feof($handle)) {

  $r = array($handle);
  $w = null;
  $e = array($handle);
  $nb = stream_select($r,$w,$e,3);
  echo "select : $nb, r=".count($r).', w='.count($w).',
e='.count($e)."\n";

  while($nb>0){
    echo "Reading...\n";
    $time = microtime(true);

    $contents = fread($handle,30);
    $delay = sprintf("%0.6f",(microtime(true)-$time));
    echo "Contents(delay:$delay): [$contents]\n";

    $r = array($handle);
    $w = null;
    $e = array($handle);
    $nb = stream_select($r,$w,$e,3);
    echo "select : $nb, r=".count($r).', w='.count($w).',
e='.count($e)."\n";
  }

  usleep(20000);
}
fclose($handle);
?>


Expected result:
----------------
select : 1, r=1, w=0, e=0
Reading...
Contents(delay:0.000124): [220 naxos2.unice.fr ESMTP Send]
select : 1, r=1, w=0, e=1
Reading...
Contents(delay:0.000011): [mail 8.13.1/8.13.1; Fri, 21 Se]
select : 1, r=1, w=0, e=1
Reading...
Contents(delay:0.000087): [p 2007 01:55:13 +0200
]
select : 0, r=0, w=0, e=0
select : 0, r=0, w=0, e=0


Actual result:
--------------
select : 1, r=1, w=0, e=0
Reading...
Contents(delay:0.000053): [220 naxos2.unice.fr ESMTP Send]
select : 1, r=1, w=0, e=1
Reading...
Contents(delay:0.000010): [mail 8.13.1/8.13.1; Fri, 21 Se]
select : 1, r=1, w=0, e=1
Reading...
Contents(delay:60.004428): [p 2007 01:53:18 +0200
]
select : 0, r=0, w=0, e=0
select : 0, r=0, w=0, e=0



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=42720&edit=1

Reply via email to