Merge r4336:

Microoptimization of sendfile(2) usage under FreeBSD.

FreeBSD kernel checks headers/trailers pointer against NULL, not
corresponding count.  Passing NULL if there are no headers/trailers
helps to avoid unneeded work in kernel, as well as unexpected 0 bytes
GIO in traces.
This commit is contained in:
Maxim Dounin 2012-02-05 12:42:36 +00:00
parent ed3d2814b9
commit 59308b99b9
1 changed files with 7 additions and 2 deletions

View File

@ -246,9 +246,14 @@ ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
}
}
hdtr.headers = (struct iovec *) header.elts;
/*
* sendfile() does unneeded work if sf_hdtr's count is 0,
* but corresponding pointer is not NULL
*/
hdtr.headers = header.nelts ? (struct iovec *) header.elts: NULL;
hdtr.hdr_cnt = header.nelts;
hdtr.trailers = (struct iovec *) trailer.elts;
hdtr.trailers = trailer.nelts ? (struct iovec *) trailer.elts: NULL;
hdtr.trl_cnt = trailer.nelts;
/*