]> granicus.if.org Git - php/commitdiff
(php_sockwait_for_data) clean up
authorSascha Schumann <sas@php.net>
Sat, 15 Jan 2000 19:51:44 +0000 (19:51 +0000)
committerSascha Schumann <sas@php.net>
Sat, 15 Jan 2000 19:51:44 +0000 (19:51 +0000)
ext/standard/fsock.c

index 13ce0e72f3ef45ce6f9af85b8d4fb290b5daf4a7..2db885931a357e6dc79e5bca1b02b94b4a1af872 100644 (file)
@@ -532,24 +532,27 @@ static void php_sockwait_for_data(php_sockbuf *sock)
 {
        fd_set fdr, tfdr;
        int retval;
-       struct timeval timeout;
+       struct timeval timeout, *ptimeout;
 
        FD_ZERO(&fdr);
        FD_SET(sock->socket, &fdr);
        sock->timeout_event = 0;
 
+       if (timeout.tv_sec == -1) 
+               ptimeout = NULL;
+       else
+               ptimeout = &timeout;
+
        while(1) {
                tfdr = fdr;
                timeout = sock->timeout;
-               if (timeout.tv_sec == -1)
-                       retval = select(sock->socket + 1, &tfdr, NULL, NULL, NULL);
-               else {
-                       retval = select(sock->socket + 1, &tfdr, NULL, NULL, &timeout);
-                       if (retval == 0)
-                               sock->timeout_event = 1;
-               }
 
-               if(retval == 1 || retval == 0)
+               retval = select(sock->socket + 1, &tfdr, NULL, NULL, ptimeout);
+               
+               if (retval == 0)
+                       sock->timeout_event = 1;
+
+               if (retval >= 0)
                        break;
        }
 }