nginx-0.0.1-2003-10-21-20:49:56 import
diff --git a/src/os/unix/ngx_freebsd_sendfile_chain.c b/src/os/unix/ngx_freebsd_sendfile_chain.c
index 1633b2f..1632424 100644
--- a/src/os/unix/ngx_freebsd_sendfile_chain.c
+++ b/src/os/unix/ngx_freebsd_sendfile_chain.c
@@ -154,6 +154,11 @@
hdtr.trailers = (struct iovec *) trailer.elts;
hdtr.trl_cnt = trailer.nelts;
+ /*
+ * the old sendfile() "nbytes bug":
+ * http://www.freebsd.org/cgi/query-pr.cgi?pr=33771
+ */
+
if (ngx_freebsd_sendfile_nbytes_bug == 0) {
hsize = 0;
}
@@ -194,7 +199,6 @@
if (rc == -1) {
err = ngx_errno;
if (err == NGX_EAGAIN) {
- eagain = 1;
ngx_log_error(NGX_LOG_INFO, c->log, err, "writev() EAGAIN");
} else if (err == NGX_EINTR) {
@@ -256,6 +260,11 @@
in = ce;
if (eagain) {
+ /*
+ * sendfile() can return EAGAIN even if it has sent
+ * a whole file part and successive sendfile() would
+ * return EAGAIN right away and would not send anything.
+ */
c->write->ready = 0;
break;
}