diff options
author | Maxim Dounin <mdounin@mdounin.ru> | 2011-12-11 16:30:42 +0000 |
---|---|---|
committer | Maxim Dounin <mdounin@mdounin.ru> | 2011-12-11 16:30:42 +0000 |
commit | ae0e919135b7e1e80167d09b5bd2fef7903f7659 (patch) | |
tree | a5f390dae59ed792dc9140b68e4188ae7cb4e4a7 /src | |
parent | 8d3ef1a3b320f786d06170d5831555aa3910de64 (diff) | |
download | nginx-ae0e919135b7e1e80167d09b5bd2fef7903f7659.tar.gz nginx-ae0e919135b7e1e80167d09b5bd2fef7903f7659.zip |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/os/unix/ngx_freebsd_sendfile_chain.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/os/unix/ngx_freebsd_sendfile_chain.c b/src/os/unix/ngx_freebsd_sendfile_chain.c index 039243e96..8c98f8e38 100644 --- 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_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; /* |