summaryrefslogtreecommitdiff
path: root/sapi/thttpd
diff options
context:
space:
mode:
authorSascha Schumann <sas@php.net>2001-01-10 13:51:58 +0000
committerSascha Schumann <sas@php.net>2001-01-10 13:51:58 +0000
commitae92ebb92bfec7f263d4e901bc23c06a6b3c3265 (patch)
tree35a826b7ab4e97a6fc53b91b2e1c4901ee04a6d7 /sapi/thttpd
parent6871b839b554bb86679e3c24a2baf1e1e7a4a7fd (diff)
downloadphp-git-ae92ebb92bfec7f263d4e901bc23c06a6b3c3265.tar.gz
Especially on FreeBSD it seems to be common that send(2) does not
do a decent job. We handle that better now.
Diffstat (limited to 'sapi/thttpd')
-rw-r--r--sapi/thttpd/thttpd.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/sapi/thttpd/thttpd.c b/sapi/thttpd/thttpd.c
index 7c37606a4b..947e00c9d9 100644
--- a/sapi/thttpd/thttpd.c
+++ b/sapi/thttpd/thttpd.c
@@ -42,17 +42,26 @@ static php_thttpd_globals thttpd_globals;
static int sapi_thttpd_ub_write(const char *str, uint str_length)
{
int n;
+ uint sent = 0;
TLS_FETCH();
- n = send(TG(hc)->conn_fd, str, str_length, 0);
-
- if (n == -1 && errno == EPIPE) {
- php_handle_aborted_connection();
+ while (str_length > 0) {
+ n = send(TG(hc)->conn_fd, str, str_length, 0);
+
+ if (n == -1 && errno == EPIPE)
+ php_handle_aborted_connection();
+ if (n == -1 && errno == EAGAIN)
+ continue;
+ if (n <= 0)
+ return n;
+
+ TG(hc)->bytes += n;
+ str += n;
+ sent += n;
+ str_length -= n;
}
- TG(hc)->bytes += n;
-
- return n;
+ return sent;
}
static int sapi_thttpd_send_headers(sapi_headers_struct *sapi_headers SLS_DC)