comparison src/os/unix/ngx_freebsd_sendfile_chain.c @ 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 d3568507db51
children d620f497c50f
comparison
equal deleted inserted replaced
4433:dfb04ceb266f 4434:80df7b82d3c9
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