[nginx] svn commit: r4435 - in branches/stable-1.0: . src/os/unix

mdounin at mdounin.ru mdounin at mdounin.ru
Sun Feb 5 12:42:36 UTC 2012


Author: mdounin
Date: 2012-02-05 12:42:36 +0000 (Sun, 05 Feb 2012)
New Revision: 4435

Log:
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.


Modified:
   branches/stable-1.0/
   branches/stable-1.0/src/os/unix/ngx_freebsd_sendfile_chain.c


Property changes on: branches/stable-1.0
___________________________________________________________________
Modified: svn:mergeinfo
   - /trunk:3960-3974,3977-3987,3991-3996,3998,4000-4018,4020,4023,4025-4027,4034-4065,4073,4077,4086-4090,4094-4102,4106-4108,4113-4114,4129-4137,4143-4144,4147-4158,4177,4179,4182-4184,4186-4187,4189-4205,4207,4209-4210,4212,4217-4223,4227-4232,4235-4237,4265-4268,4270,4274-4276,4278-4280,4282-4284,4294-4295,4298,4300-4309,4313,4315,4320-4321,4326-4327,4335,4342-4343,4377
   + /trunk:3960-3974,3977-3987,3991-3996,3998,4000-4018,4020,4023,4025-4027,4034-4065,4073,4077,4086-4090,4094-4102,4106-4108,4113-4114,4129-4137,4143-4144,4147-4158,4177,4179,4182-4184,4186-4187,4189-4205,4207,4209-4210,4212,4217-4223,4227-4232,4235-4237,4265-4268,4270,4274-4276,4278-4280,4282-4284,4294-4295,4298,4300-4309,4313,4315,4320-4321,4326-4327,4335-4336,4342-4343,4377

Modified: branches/stable-1.0/src/os/unix/ngx_freebsd_sendfile_chain.c
===================================================================
--- branches/stable-1.0/src/os/unix/ngx_freebsd_sendfile_chain.c	2012-02-05 12:37:48 UTC (rev 4434)
+++ branches/stable-1.0/src/os/unix/ngx_freebsd_sendfile_chain.c	2012-02-05 12:42:36 UTC (rev 4435)
@@ -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