[PHP-DEV] PHP 4.0 Bug #9347 Updated: php_read does not handle O_NONBLOCK correctly From: tem <email protected>
Date: 02/19/01

ID: 9347
User Update by: tem <email protected>
Status: Open
Bug Type: Sockets related
Description: php_read does not handle O_NONBLOCK correctly

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

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

[2001-02-19 17:11:44] tem <email protected>
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

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

Full Bug description available at: http://bugs.php.net/?id=9347

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: php-dev-unsubscribe <email protected>
For additional commands, e-mail: php-dev-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>