Mercurial > hg > nginx-quic
changeset 4434:80df7b82d3c9 stable-1.0
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.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Sun, 05 Feb 2012 12:42:36 +0000 |
parents | dfb04ceb266f |
children | 3b9be99122b6 |
files | src/os/unix/ngx_freebsd_sendfile_chain.c |
diffstat | 1 files changed, 7 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/os/unix/ngx_freebsd_sendfile_chain.c +++ b/src/os/unix/ngx_freebsd_sendfile_chain.c @@ -246,9 +246,14 @@ ngx_freebsd_sendfile_chain(ngx_connectio } } - 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; /*