# PATCH: Bug #51056 fread() on blocking stream will block even if data is available

- Thread: https://externals.io/message/46997
- Original archive: https://news-web.php.net/php.internals/46997
- Started by Mark Karpeles on 2010-02-17T16:15:29+00:00
- Messages: 1
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #46997 — Mark Karpeles — 2010-02-17T16:15:29+00:00

URL: https://externals.io/message/46997#46997

Hi,

Got some troubles since a long time ago with `fread()` on blocking
streams, and found a bug with `fread()` when reading a blocking stream
with a buffer too small to contain all the received data.

http://bugs.php.net/bug.php?id=51056

I've made a patch on PHP_5_3, and wish to hear about it (and if it's
good, wish to see it applied).

http://ookoo.org/svn/snip/php-PHP_5_3-streams-socket-blocking-nostuck.patch

The change should be pretty much the same for PHP_5_2 (which exhibits
the same bug).

Test script is available in the bug report to see that the fix is indeed
effective.


Mark
