php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #28964 fread "gready" behaviour
Submitted: 2004-06-29 23:49 UTC Modified: 2004-06-29 23:52 UTC
From: aidan@php.net Assigned:
Status: Closed Package: Sockets related
PHP Version: 4.3.7 OS: N/A
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
45 + 21 = ?
Subscribe to this entry?

 
 [2004-06-29 23:49 UTC] aidan@php.net
Description:
------------
When grabbing code with fread it exhibits "gready" behaviour. i.e. It does not ignore packet boundaries.

We expect to get 6 packets when using fread 6 times. PHP currently joins the packets together into 3 packets. I assume it keeps those packets seperate because they have different source ips.

Reproduce code:
---------------
Tests run with: http://nopaste.php.cd/20417

Expected result:
----------------
With modified source, the expected result:

recv(3, "\377\377\377\377j\0", 8192, 0) = 6
recv(3, "\377\377\377\377j\0", 8192, 0) = 6
recv(7, "\377\377\377\377j\0", 8192, 0) = 6
recv(7, "\377\377\377\377j\0", 8192, 0) = 6
recv(8, "\377\377\377\377j\0", 8192, 0) = 6
recv(8, "\377\377\377\377j\0", 8192, 0) = 6
1 6
2 6
3 6
4 6
5 6
6 6

Actual result:
--------------
Strace:
recv(4, "\377\377\377\377j\0", 8192, 0) = 6
recv(4, "\377\377\377\377j\0", 8192, 0) = 6
recv(4, 0x82d3bfc, 8192, 0)             = -1 EAGAIN (Resource temporarily unavailable)
recv(8, "\377\377\377\377j\0", 8192, 0) = 6
recv(8, "\377\377\377\377j\0", 8192, 0) = 6
recv(8, 0x82dc984, 8192, 0)             = -1 EAGAIN (Resource temporarily unavailable)
recv(9, "\377\377\377\377j\0", 8192, 0) = 6
recv(9, "\377\377\377\377j\0", 8192, 0) = 6
recv(9, 0x82de994, 8192, 0)             = -1 EAGAIN (Resource temporarily unavailable)

PHP Script output: (packet + size)
1 12
2 12
3 12


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-06-29 23:52 UTC] wez@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Mon Aug 08 05:03:33 2022 UTC