summaryrefslogtreecommitdiff
path: root/sapi/tux/php_tux.c
diff options
context:
space:
mode:
authorSascha Schumann <sas@php.net>2002-03-04 08:25:20 (GMT)
committerSascha Schumann <sas@php.net>2002-03-04 08:25:20 (GMT)
commita2065b8743808235f3f81cbb11a9dd0ea13988e3 (patch)
tree31f0ee2c2d0f54d607a477f8782656d5f3cf8a09 /sapi/tux/php_tux.c
parent66535c240ef1a2bb6b942057597de2dd746c3fce (diff)
downloadphp-a2065b8743808235f3f81cbb11a9dd0ea13988e3.tar.gz
Reduce operations in the ub_write loop.
Diffstat (limited to 'sapi/tux/php_tux.c')
-rw-r--r--sapi/tux/php_tux.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/sapi/tux/php_tux.c b/sapi/tux/php_tux.c
index 7990cff..16a7be8 100644
--- a/sapi/tux/php_tux.c
+++ b/sapi/tux/php_tux.c
@@ -52,8 +52,8 @@ static php_tux_globals tux_globals;
static int sapi_tux_ub_write(const char *str, uint str_length TSRMLS_DC)
{
int n;
- uint sent = 0;
int m;
+ const char *estr;
/* combine headers and body */
if (TG(number_vec)) {
@@ -73,9 +73,11 @@ static int sapi_tux_ub_write(const char *str, uint str_length TSRMLS_DC)
TG(number_vec) = 0;
return str_length;
}
+
+ estr = str + str_length;
- while (str_length > 0) {
- n = send(TG(req)->sock, str, str_length, 0);
+ while (str < estr) {
+ n = send(TG(req)->sock, str, estr - str, 0);
if (n == -1 && errno == EPIPE)
php_handle_aborted_connection();
@@ -84,13 +86,14 @@ static int sapi_tux_ub_write(const char *str, uint str_length TSRMLS_DC)
if (n <= 0)
return n;
- TG(req)->bytes_sent += n;
str += n;
- sent += n;
- str_length -= n;
}
- return sent;
+ n = str_length - (estr - str);
+
+ TG(req)->bytes_sent += n;
+
+ return n;
}
static int sapi_tux_send_headers(sapi_headers_struct *sapi_headers)