]> git.kaiwu.me - nginx.git/commitdiff
Generalized definitions of the number of preallocated iovec's.
authorValentin Bartenev <vbart@nginx.com>
Wed, 13 Aug 2014 11:11:45 +0000 (15:11 +0400)
committerValentin Bartenev <vbart@nginx.com>
Wed, 13 Aug 2014 11:11:45 +0000 (15:11 +0400)
No functional changes.

src/os/unix/ngx_darwin_sendfile_chain.c
src/os/unix/ngx_freebsd_sendfile_chain.c
src/os/unix/ngx_linux_sendfile_chain.c
src/os/unix/ngx_os.h
src/os/unix/ngx_readv_chain.c
src/os/unix/ngx_solaris_sendfilev_chain.c
src/os/unix/ngx_writev_chain.c

index 67b740bd2d8f9849c84210fa953f66a555b63358..dd574e5ac907325d7dcd23adcb3cb4ecd58df802 100644 (file)
  */
 
 
-#if (IOV_MAX > 64)
-#define NGX_HEADERS   64
-#define NGX_TRAILERS  64
-#else
-#define NGX_HEADERS   IOV_MAX
-#define NGX_TRAILERS  IOV_MAX
-#endif
-
-
 ngx_chain_t *
 ngx_darwin_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
 {
@@ -50,7 +41,9 @@ ngx_darwin_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
     ngx_event_t     *wev;
     ngx_chain_t     *cl;
     struct sf_hdtr   hdtr;
-    struct iovec    *iov, headers[NGX_HEADERS], trailers[NGX_TRAILERS];
+    struct iovec    *iov;
+    struct iovec     headers[NGX_IOVS_PREALLOCATE];
+    struct iovec     trailers[NGX_IOVS_PREALLOCATE];
 
     wev = c->write;
 
@@ -79,12 +72,12 @@ ngx_darwin_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
 
     header.elts = headers;
     header.size = sizeof(struct iovec);
-    header.nalloc = NGX_HEADERS;
+    header.nalloc = NGX_IOVS_PREALLOCATE;
     header.pool = c->pool;
 
     trailer.elts = trailers;
     trailer.size = sizeof(struct iovec);
-    trailer.nalloc = NGX_TRAILERS;
+    trailer.nalloc = NGX_IOVS_PREALLOCATE;
     trailer.pool = c->pool;
 
     for ( ;; ) {
index 09f66a2c65a261faad437af5b8d99145e1748a11..f5d0f3a8aa19864036bf4b02fcf14ccfef2d9900 100644 (file)
  */
 
 
-#if (IOV_MAX > 64)
-#define NGX_HEADERS   64
-#define NGX_TRAILERS  64
-#else
-#define NGX_HEADERS   IOV_MAX
-#define NGX_TRAILERS  IOV_MAX
-#endif
-
-
 ngx_chain_t *
 ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
 {
@@ -52,7 +43,9 @@ ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
     ngx_event_t     *wev;
     ngx_chain_t     *cl;
     struct sf_hdtr   hdtr;
-    struct iovec    *iov, headers[NGX_HEADERS], trailers[NGX_TRAILERS];
+    struct iovec    *iov;
+    struct iovec     headers[NGX_IOVS_PREALLOCATE];
+    struct iovec     trailers[NGX_IOVS_PREALLOCATE];
 
     wev = c->write;
 
@@ -83,12 +76,12 @@ ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
 
     header.elts = headers;
     header.size = sizeof(struct iovec);
-    header.nalloc = NGX_HEADERS;
+    header.nalloc = NGX_IOVS_PREALLOCATE;
     header.pool = c->pool;
 
     trailer.elts = trailers;
     trailer.size = sizeof(struct iovec);
-    trailer.nalloc = NGX_TRAILERS;
+    trailer.nalloc = NGX_IOVS_PREALLOCATE;
     trailer.pool = c->pool;
 
     for ( ;; ) {
index 48b5a71a1992fbadf9c3d4ac354bc8340739a795..1060852a0cd8f77631f95742e929b498ac50af2a 100644 (file)
 #define NGX_SENDFILE_MAXSIZE  2147483647L
 
 
-#if (IOV_MAX > 64)
-#define NGX_HEADERS  64
-#else
-#define NGX_HEADERS  IOV_MAX
-#endif
-
-
 ngx_chain_t *
 ngx_linux_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
 {
@@ -47,7 +40,7 @@ ngx_linux_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
     ngx_array_t    header;
     ngx_event_t   *wev;
     ngx_chain_t   *cl;
-    struct iovec  *iov, headers[NGX_HEADERS];
+    struct iovec  *iov, headers[NGX_IOVS_PREALLOCATE];
 #if (NGX_HAVE_SENDFILE64)
     off_t          offset;
 #else
@@ -72,7 +65,7 @@ ngx_linux_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
 
     header.elts = headers;
     header.size = sizeof(struct iovec);
-    header.nalloc = NGX_HEADERS;
+    header.nalloc = NGX_IOVS_PREALLOCATE;
     header.pool = c->pool;
 
     for ( ;; ) {
index c646e2aa5a8a6a856e995d074d53c49977353a11..1033d88251e582a0815d652c810b71b853514921 100644 (file)
@@ -56,6 +56,13 @@ ngx_chain_t *ngx_aio_write_chain(ngx_connection_t *c, ngx_chain_t *in,
 #endif
 
 
+#if (IOV_MAX > 64)
+#define NGX_IOVS_PREALLOCATE  64
+#else
+#define NGX_IOVS_PREALLOCATE  IOV_MAX
+#endif
+
+
 extern ngx_os_io_t  ngx_os_io;
 extern ngx_int_t    ngx_ncpu;
 extern ngx_int_t    ngx_max_sockets;
index 925034c53d02a2228acac7ff3ede6ce3827a5957..8523be3672ecd78ca6ba5ac617b8a5fed69fb75f 100644 (file)
 #include <ngx_event.h>
 
 
-#if (IOV_MAX > 64)
-#define NGX_IOVS  64
-#else
-#define NGX_IOVS  IOV_MAX
-#endif
-
-
 ssize_t
 ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *chain)
 {
@@ -25,7 +18,7 @@ ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *chain)
     ngx_err_t      err;
     ngx_array_t    vec;
     ngx_event_t   *rev;
-    struct iovec  *iov, iovs[NGX_IOVS];
+    struct iovec  *iov, iovs[NGX_IOVS_PREALLOCATE];
 
     rev = c->read;
 
@@ -67,7 +60,7 @@ ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *chain)
     vec.elts = iovs;
     vec.nelts = 0;
     vec.size = sizeof(struct iovec);
-    vec.nalloc = NGX_IOVS;
+    vec.nalloc = NGX_IOVS_PREALLOCATE;
     vec.pool = c->pool;
 
     /* coalesce the neighbouring bufs */
index 1afe5ac193cf56841c00c7543b99eafbe9d64fce..ba328c810da83bdc5f92d6515507ef1a6a882ca1 100644 (file)
@@ -35,12 +35,7 @@ ngx_chain_t *ngx_solaris_sendfilev_chain(ngx_connection_t *c, ngx_chain_t *in,
 #endif
 
 
-#if (IOV_MAX > 64)
-#define NGX_SENDFILEVECS  64
-#else
-#define NGX_SENDFILEVECS  IOV_MAX
-#endif
-
+#define NGX_SENDFILEVECS  NGX_IOVS_PREALLOCATE
 
 
 ngx_chain_t *
index f67c3a3c9501c30a97dab4fa2a66adb054786300..95af2da7a3428f8a60c1abc817ad56be2d100fc7 100644 (file)
 #include <ngx_event.h>
 
 
-#if (IOV_MAX > 64)
-#define NGX_IOVS  64
-#else
-#define NGX_IOVS  IOV_MAX
-#endif
-
-
 ngx_chain_t *
 ngx_writev_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
 {
@@ -28,7 +21,7 @@ ngx_writev_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
     ngx_array_t    vec;
     ngx_chain_t   *cl;
     ngx_event_t   *wev;
-    struct iovec  *iov, iovs[NGX_IOVS];
+    struct iovec  *iov, iovs[NGX_IOVS_PREALLOCATE];
 
     wev = c->write;
 
@@ -57,7 +50,7 @@ ngx_writev_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
 
     vec.elts = iovs;
     vec.size = sizeof(struct iovec);
-    vec.nalloc = NGX_IOVS;
+    vec.nalloc = NGX_IOVS_PREALLOCATE;
     vec.pool = c->pool;
 
     for ( ;; ) {