]> granicus.if.org Git - php/commitdiff
Fix reading from remote on some *nixes
authorBob Weinand <bobwei9@hotmail.com>
Mon, 20 Oct 2014 06:46:22 +0000 (08:46 +0200)
committerBob Weinand <bobwei9@hotmail.com>
Mon, 20 Oct 2014 06:46:22 +0000 (08:46 +0200)
phpdbg_cmd.c
phpdbg_io.c

index ae4925c5a2b9f256463f3139705a08e1df464c3e..c09df70a41422dfb23efddb7e5049e80864d2af0 100644 (file)
@@ -23,6 +23,7 @@
 #include "phpdbg_utils.h"
 #include "phpdbg_set.h"
 #include "phpdbg_prompt.h"
+#include "phpdbg_io.h"
 
 ZEND_EXTERN_MODULE_GLOBALS(phpdbg);
 
@@ -863,7 +864,7 @@ readline:
                                        }
                                        len += bytes;
                                        /* XXX export the timeout through INI??*/
-                               } while ((bytes = phpdbg_mixed_read(PHPDBG_G(io)[PHPDBG_STDIN].fd, buf + len, PHPDBG_MAX_CMD - len, -1)) > 0 || (errno == EINTR && bytes < 0));
+                               } while ((bytes = phpdbg_mixed_read(PHPDBG_G(io)[PHPDBG_STDIN].fd, buf + len, PHPDBG_MAX_CMD - len, -1 TSRMLS_CC)) > 0 || (errno == EINTR && bytes < 0));
 
                                if (bytes <= 0) {
                                        goto disconnect;
index 79fd55957dfef05a001f4182c2876abecdb264cf..753779a5df70a3448356f4f43e71e5880a78cd9e 100644 (file)
@@ -88,10 +88,22 @@ recv_once:
                        /* There's something to read. Read what's available and proceed
                        disregarding whether len could be exhausted or not.*/
                        int can_read = recv(sock, p, i, MSG_PEEK);
+#ifndef _WIN32
+                       if (can_read == -1 && errno == EINTR) {
+                               continue;
+                       }
+#endif
                        i = can_read;
                }
 
+#ifdef _WIN32
                got_now = recv(sock, p, i, 0);
+#else
+               do {
+                       got_now = recv(sock, p, i, 0);
+               } while (got_now == -1 && errno == EINTR);
+#endif
+
                if (got_now == -1) {
                        write(PHPDBG_G(io)[PHPDBG_STDERR].fd, ZEND_STRL("Read operation timed out!\n"));
                        return -1;