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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: aidan@php.net
New email:
PHP Version: OS:

 

 [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-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 23:01:26 2024 UTC