#42720 [Opn->Fbk]: fread timeout with available datas
| From: | jani@php.net | Date: | Mon, 14 Jul 2008 21:23:27 +0000 |
| Subject: | #42720 [Opn->Fbk]: fread timeout with available datas | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-126708@lists.php.net to get a copy of this message | ||
ID: 42720
Updated by: jani@php.net
Reported By: Slig at free dot fr
-Status: Open
+Status: Feedback
Bug Type: Streams related
Operating System: *
PHP Version: 5CVS-2007-09-21 (snap)
New Comment:
Please try using this CVS snapshot:
http://snaps.php.net/php5.2-latest.tar.gz
For Windows (zip):
http://snaps.php.net/win32/php5.2-win32-latest.zip
For Windows (installer):
http://snaps.php.net/win32/php5.2-win32-installer-latest.msi
Previous Comments:
------------------------------------------------------------------------
[2007-09-25 07:18:27] Slig at free dot fr
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.
------------------------------------------------------------------------
[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