comparison src/os/unix/ngx_freebsd_sendfile_chain.c @ 5854:b63e829621ab

Generalized definitions of the number of preallocated iovec's. No functional changes.
author Valentin Bartenev <vbart@nginx.com>
date Wed, 13 Aug 2014 15:11:45 +0400
parents 150df089fe47
children 6bbad2e73245
comparison
equal deleted inserted replaced
5853:a6e83ac70af9 5854:b63e829621ab
27 * So we do not use TCP_NOPUSH on FreeBSD prior to 4.5, although it can be used 27 * So we do not use TCP_NOPUSH on FreeBSD prior to 4.5, although it can be used
28 * for non-keepalive HTTP connections. 28 * for non-keepalive HTTP connections.
29 */ 29 */
30 30
31 31
32 #if (IOV_MAX > 64)
33 #define NGX_HEADERS 64
34 #define NGX_TRAILERS 64
35 #else
36 #define NGX_HEADERS IOV_MAX
37 #define NGX_TRAILERS IOV_MAX
38 #endif
39
40
41 ngx_chain_t * 32 ngx_chain_t *
42 ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit) 33 ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
43 { 34 {
44 int rc, flags; 35 int rc, flags;
45 u_char *prev; 36 u_char *prev;
50 ngx_buf_t *file; 41 ngx_buf_t *file;
51 ngx_array_t header, trailer; 42 ngx_array_t header, trailer;
52 ngx_event_t *wev; 43 ngx_event_t *wev;
53 ngx_chain_t *cl; 44 ngx_chain_t *cl;
54 struct sf_hdtr hdtr; 45 struct sf_hdtr hdtr;
55 struct iovec *iov, headers[NGX_HEADERS], trailers[NGX_TRAILERS]; 46 struct iovec *iov;
47 struct iovec headers[NGX_IOVS_PREALLOCATE];
48 struct iovec trailers[NGX_IOVS_PREALLOCATE];
56 49
57 wev = c->write; 50 wev = c->write;
58 51
59 if (!wev->ready) { 52 if (!wev->ready) {
60 return in; 53 return in;
81 eagain = 0; 74 eagain = 0;
82 flags = 0; 75 flags = 0;
83 76
84 header.elts = headers; 77 header.elts = headers;
85 header.size = sizeof(struct iovec); 78 header.size = sizeof(struct iovec);
86 header.nalloc = NGX_HEADERS; 79 header.nalloc = NGX_IOVS_PREALLOCATE;
87 header.pool = c->pool; 80 header.pool = c->pool;
88 81
89 trailer.elts = trailers; 82 trailer.elts = trailers;
90 trailer.size = sizeof(struct iovec); 83 trailer.size = sizeof(struct iovec);
91 trailer.nalloc = NGX_TRAILERS; 84 trailer.nalloc = NGX_IOVS_PREALLOCATE;
92 trailer.pool = c->pool; 85 trailer.pool = c->pool;
93 86
94 for ( ;; ) { 87 for ( ;; ) {
95 file = NULL; 88 file = NULL;
96 file_size = 0; 89 file_size = 0;