|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2009-09-29 06:20 UTC] alex at innovacomputing dot com
Description: ------------ feof() seems to have broken on socket streams somewhere between version 5.2.9 and 5.2.11. When running the code included in this bug report on PHP 5.2.9, it returns "bool(false)", which is the correct behavior. However, when upgrading to PHP 5.2.11, feof() will incorrectly return "bool(true)". Note that I've only been able to reproduce this on a 64-bit server. PHP 5.2.11 on the 32-bit server that I've also tested with correctly returns "bool(false)". Reproduce code: --------------- <?php list($a, $b) = stream_socket_pair(STREAM_PF_UNIX, STREAM_SOCK_STREAM, STREAM_IPPROTO_IP); fwrite($a, 'Test'); var_dump(feof($b)); Expected result: ---------------- bool(false) Actual result: -------------- bool(true) PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 20:00:01 2025 UTC |
Problem is manifesting itself in Mantis 1.1.0a1 with mail reporting script running on SunOS Machine hardware: sun4u OS version: 5.10 Processor type: sparc Hardware: SUNW,Ultra-250 feof erroneously returns true when reading from a socket to the POP3 server ( Qpopper version 4.1b18). This results in readLine in socket.php randomly returning an empty string when called from _recvLn() in POP3.PHP , so this breaks all the functions in POP3.PHP Commenting out feof in readLine fixes this problem: function readLine() { if (!is_resource($this->fp)) { return $this->raiseError('not connected'); } $line = ''; $timeout = time() + $this->timeout; while (/* !feof($this->fp) && */ (!$this->timeout || time() < $timeout)) { $line .= @fgets($this->fp, $this->lineLength); if (substr($line, -1) == "\n") { return rtrim($line, "\r\n"); } } return $line; } As feof( ) seems to randomly return true I suspect a timing issue, probably depends on whether the mail server has written to the socket before feof is called - our mail server resides on another server. Could this be related to the fix for PHP bug 49072 (feof never returns true for damaged file in zip). http://bugs.php.net/bug.php?id=49072 ? It is fixed in the latest version ( 5.12 release candidate 2 ).