[nginx] svn commit: r4336 - trunk/src/os/unix
mdounin at mdounin.ru
mdounin at mdounin.ru
Sun Dec 11 16:30:43 UTC 2011
Author: mdounin
Date: 2011-12-11 16:30:42 +0000 (Sun, 11 Dec 2011)
New Revision: 4336
Log:
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.
Modified:
trunk/src/os/unix/ngx_freebsd_sendfile_chain.c
Modified: trunk/src/os/unix/ngx_freebsd_sendfile_chain.c
===================================================================
--- trunk/src/os/unix/ngx_freebsd_sendfile_chain.c 2011-12-09 16:17:12 UTC (rev 4335)
+++ trunk/src/os/unix/ngx_freebsd_sendfile_chain.c 2011-12-11 16:30:42 UTC (rev 4336)
@@ -246,9 +246,14 @@
}
}
- 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;
/*
More information about the nginx-devel
mailing list