#47289 [NoF->Csd]: socket_read falls into endless loop if remote host disconnects

[email protected] ("patryk dot szczyglowski at gmail dot com")
Newsgroups php.bugs
Message-ID <[email protected]>
 ID:               47289
 User updated by:  patryk dot szczyglowski at gmail dot com
 Reported By:      patryk dot szczyglowski at gmail dot com
-Status:           No Feedback
+Status:           Closed
 Bug Type:         Sockets related
 Operating System: Linux 2.6
 PHP Version:      5.2.8
 New Comment:

It seems that the patch fixes the problem. Thanks!


Previous Comments:
------------------------------------------------------------------------

[2009-02-19 01:00:03] 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".

------------------------------------------------------------------------

[2009-02-11 15:44:21] [email protected]

Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/



------------------------------------------------------------------------

[2009-02-11 15:35:16] patryk dot szczyglowski at gmail dot com

The information has been provided a week ago.

------------------------------------------------------------------------

[2009-02-11 01:00:00] 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".

------------------------------------------------------------------------

[2009-02-04 14:50:45] patryk dot szczyglowski at gmail dot com

In php documentation:
"socket_read() returns the data as a string on success, or FALSE on
error (including if the remote host has closed the connection)."

So I used:

while (($res = socket_read(...)) !== false) {
  // .. do something
}

To correct it without changes in PHP source code this loop should
look:

while ($res != false) {
  // .. do something
}

but that's incorrect, because e.g. string '0' will match the condition
and it is perfectly valid content.

Low level recv() function returns 0 only on disconnect, and while
connected in blocking mode 0 is never returned to the application.
Current PHP implementation is not compatible with recv(2) and PHP
documentation.

So either you commit my patch or correct the documentation.

Thanks.

------------------------------------------------------------------------

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/47289

-- 
Edit this bug report at http://bugs.php.net/?id=47289&edit=1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.