Mercurial > hg > nginx
comparison src/os/unix/ngx_freebsd_sendfile_chain.c @ 4335:1003326eccc5
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, 11 Dec 2011 16:30:42 +0000 |
parents | 59b99f217c6d |
children | d620f497c50f |
comparison
equal
deleted
inserted
replaced
4334:f8881d301d62 | 4335:1003326eccc5 |
---|---|
244 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, 0, | 244 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, 0, |
245 "tcp_nopush"); | 245 "tcp_nopush"); |
246 } | 246 } |
247 } | 247 } |
248 | 248 |
249 hdtr.headers = (struct iovec *) header.elts; | 249 /* |
250 * sendfile() does unneeded work if sf_hdtr's count is 0, | |
251 * but corresponding pointer is not NULL | |
252 */ | |
253 | |
254 hdtr.headers = header.nelts ? (struct iovec *) header.elts: NULL; | |
250 hdtr.hdr_cnt = header.nelts; | 255 hdtr.hdr_cnt = header.nelts; |
251 hdtr.trailers = (struct iovec *) trailer.elts; | 256 hdtr.trailers = trailer.nelts ? (struct iovec *) trailer.elts: NULL; |
252 hdtr.trl_cnt = trailer.nelts; | 257 hdtr.trl_cnt = trailer.nelts; |
253 | 258 |
254 /* | 259 /* |
255 * the "nbytes bug" of the old sendfile() syscall: | 260 * the "nbytes bug" of the old sendfile() syscall: |
256 * http://www.freebsd.org/cgi/query-pr.cgi?pr=33771 | 261 * http://www.freebsd.org/cgi/query-pr.cgi?pr=33771 |