From 2916a14018c19fb6d38984e12eed930666dcb200 Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Mon, 20 Oct 2014 08:46:22 +0200 Subject: [PATCH] Fix reading from remote on some *nixes --- phpdbg_cmd.c | 3 ++- phpdbg_io.c | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/phpdbg_cmd.c b/phpdbg_cmd.c index ae4925c5a2..c09df70a41 100644 --- a/phpdbg_cmd.c +++ b/phpdbg_cmd.c @@ -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; diff --git a/phpdbg_io.c b/phpdbg_io.c index 79fd55957d..753779a5df 100644 --- a/phpdbg_io.c +++ b/phpdbg_io.c @@ -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; -- 2.50.1