php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42720 fread timeout with available datas
Submitted: 2007-09-21 00:01 UTC Modified: 2008-07-22 01:00 UTC
Votes:6
Avg. Score:4.8 ± 0.4
Reproduced:6 of 6 (100.0%)
Same Version:4 (66.7%)
Same OS:6 (100.0%)
From: Slig at free dot fr Assigned:
Status: No Feedback Package: Streams related
PHP Version: 5CVS-2007-09-21 (snap) OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: Slig at free dot fr
New email:
PHP Version: OS:

 

 [2007-09-21 00:01 UTC] 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


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-09-25 07:18 UTC] 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.
 [2008-07-22 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC