com php-src: several fixes to the new io stuff: phpdbg_io.c phpdbg_io.h

From: Date: Sat, 18 Oct 2014 23:32:46 +0000
Subject: com php-src: several fixes to the new io stuff: phpdbg_io.c phpdbg_io.h
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-82545@lists.php.net to get a copy of this message
Commit: 1137d9cb2bb269d73708b76349a07c36bcac13dc Author: Anatol Belski <ab@php.net> Sun, 19 Oct 2014 01:32:46 +0200 Parents: 52d2ead59d8770da166f8a6cfe0e2f4eab1bbaaa Branches: PHP-5.6 Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=1137d9cb2bb269d73708b76349a07c36bcac13dc Log: several fixes to the new io stuff Changed paths: M phpdbg_io.c M phpdbg_io.h Diff: diff --git a/phpdbg_io.c b/phpdbg_io.c index e561174..f358fbf 100644 --- a/phpdbg_io.c +++ b/phpdbg_io.c @@ -22,6 +22,35 @@ #include "phpdbg_io.h" +#ifdef PHP_WIN32 +#undef UNICODE +#include "win32/inet.h" +#include <winsock2.h> +#include <windows.h> +#include <Ws2tcpip.h> +#include "win32/sockets.h" + +#else + +#if HAVE_SYS_TYPES_H +#include <sys/types.h> +#endif +#include <sys/socket.h> +#include <netinet/in.h> +#if HAVE_ARPA_INET_H +#include <arpa/inet.h> +#endif +#include <netdb.h> + +#include <fcntl.h> + +#include <poll.h> +#endif + + +ZEND_EXTERN_MODULE_GLOBALS(phpdbg); + + PHPDBG_API int phpdbg_consume_bytes(int sock, char *ptr, int len, int tmo) {/*{{{*/ @@ -54,6 +83,11 @@ phpdbg_consume_bytes(int sock, char *ptr, int len, int tmo) } while(i > 0) { +#ifdef PHP_WIN32 + int can_read = recv(sock, p, i, MSG_PEEK); + + i = can_read; +#endif got_now = recv(sock, p, i, 0); if (got_now == -1) { return -1; @@ -62,7 +96,7 @@ phpdbg_consume_bytes(int sock, char *ptr, int len, int tmo) p += got_now; } - return len; + return p - ptr; }/*}}}*/ PHPDBG_API int @@ -83,3 +117,24 @@ phpdbg_send_bytes(int sock, char *ptr, int len) return len; }/*}}}*/ + +PHPDBG_API int +phpdbg_mixed_read(int sock, char *ptr, int len, int tmo TSRMLS_CC) +{/*{{{*/ + if (PHPDBG_G(flags) & PHPDBG_IS_REMOTE) { + return phpdbg_consume_bytes(sock, ptr, len, tmo); + } + + return read(sock, ptr, len); +}/*}}}*/ + + +PHPDBG_API int +phpdbg_mixed_write(int sock, char *ptr, int len TSRMLS_CC) +{/*{{{*/ + if (PHPDBG_G(flags) & PHPDBG_IS_REMOTE) { + return phpdbg_send_bytes(sock, ptr, len); + } + + return write(sock, ptr, len); +}/*}}}*/ diff --git a/phpdbg_io.h b/phpdbg_io.h index e293516..3c46846 100644 --- a/phpdbg_io.h +++ b/phpdbg_io.h @@ -21,37 +21,17 @@ #include "phpdbg.h" -#ifdef PHP_WIN32 -#undef UNICODE -#include "win32/inet.h" -#include <winsock2.h> -#include <windows.h> -#include <Ws2tcpip.h> -#include "win32/sockets.h" - -#else - -#if HAVE_SYS_TYPES_H -#include <sys/types.h> -#endif -#include <sys/socket.h> -#include <netinet/in.h> -#if HAVE_ARPA_INET_H -#include <arpa/inet.h> -#endif -#include <netdb.h> - -#include <fcntl.h> - -#include <poll.h> -#endif - - PHPDBG_API int phpdbg_consume_bytes(int sock, char *ptr, int len, int tmo); PHPDBG_API int phpdbg_send_bytes(int sock, char *ptr, int len); +PHPDBG_API int +phpdbg_mixed_read(int sock, char *ptr, int len, int tmo TSRMLS_CC); + +PHPDBG_API int +phpdbg_mixed_write(int sock, char *ptr, int len TSRMLS_CC); + #endif /* PHPDBG_IO_H */

« previous php.cvs (#82545) next »