php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #9347 php_read does not handle O_NONBLOCK correctly
Submitted: 2001-02-19 17:11 UTC Modified: 2001-06-12 01:08 UTC
From: tem at iocus dot com Assigned:
Status: Closed Package: Sockets related
PHP Version: 4.0 Latest CVS (19/02/2001) OS: linux (mandrake 7.2)
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: tem at iocus dot com
New email:
PHP Version: OS:

 

 [2001-02-19 17:11 UTC] tem at iocus dot com
The php_read function does not seem to handle non-blocking sockets correctly.  The read function will return a negative value when EAGAIN (no data available when in nonblocking mode) error occurs. (from the man page:
On error, -1 is returned, and errno is set  appropriately.)  Here is my quick n' dirty patch:

--- ext/sockets/mysocket.c      Mon Feb 19 16:53:20 2001
+++ ext/sockets/sockets.c       Mon Feb 19 16:52:42 2001
@@ -635,7 +635,7 @@
           if (m > 0) {
                t++;
                n++;
-          } else if (m <= 0) {
+          } else if (m == 0) {
                no_read++;
               if (nonblock && no_read >= 2) {
                        return n; /* The first pass, m always is 0, so no_read becomes 1                                    


enjoy.

-tem

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-02-19 17:37 UTC] tem at iocus dot com
err did the patch backwards.

--- ext/sockets/sockets.c       Mon Feb 19 16:52:42 2001
+++ ext/sockets/mysocket.c      Mon Feb 19 16:53:20 2001
@@ -635,7 +635,7 @@
           if (m > 0) {
                t++;
                n++;
-          } else if (m == 0) {
+          } else if (m <= 0) {
                no_read++;
               if (nonblock && no_read >= 2) {
                        return n; /* The first pass, m always is 0, so no_read becomes 1 
 [2001-06-12 01:08 UTC] sniper@php.net
This is not correct. The php_read() will loop until
it get's some data in case of EAGAIN.
(at least in latest CVS)

--Jani

 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Wed Aug 12 07:01:25 2020 UTC