php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login

Patch cli_server_send_through_fix.patch for Built-in web server Bug #55423

Patch version 2011-08-15 14:28 UTC

Return to Bug #55423 | Download this patch
Patch Revisions:

Developer: chobieee@gmail.com

--- php-5.4.0alpha3/sapi/cli/php_cli_server.c	2011-07-26 01:45:39.000000000 +0900
+++ php-5.4.0alpha3-modified/sapi/cli/php_cli_server.c	2011-08-15 23:10:04.000000000 +0900
@@ -1370,8 +1370,10 @@
 {
 	struct timeval tv = { 10, 0 };
 	ssize_t nbytes_left = str_len;
-	do {
-		ssize_t nbytes_sent = send(client->sock, str, str_len, 0);
+	char *ptr = str;
+	
+	while(nbytes_left > 0){
+		ssize_t nbytes_sent = send(client->sock, ptr, nbytes_left, 0);
 		if (nbytes_sent < 0) {
 			int err = php_socket_errno();
 			if (err == EAGAIN) {
@@ -1393,7 +1395,8 @@
 			}
 		}
 		nbytes_left -= nbytes_sent;
-	} while (nbytes_left > 0);
+		ptr += nbytes_sent;
+	}
 
 	return str_len;
 } /* }}} */
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 20:01:45 2024 UTC