comparison src/os/unix/ngx_darwin_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
25 * in different packets. And FreeBSD workaround (TCP_NOPUSH option) 25 * in different packets. And FreeBSD workaround (TCP_NOPUSH option)
26 * does not help. 26 * does not help.
27 */ 27 */
28 28
29 29
30 #if (IOV_MAX > 64)
31 #define NGX_HEADERS 64
32 #define NGX_TRAILERS 64
33 #else
34 #define NGX_HEADERS IOV_MAX
35 #define NGX_TRAILERS IOV_MAX
36 #endif
37
38
39 ngx_chain_t * 30 ngx_chain_t *
40 ngx_darwin_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit) 31 ngx_darwin_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
41 { 32 {
42 int rc; 33 int rc;
43 u_char *prev; 34 u_char *prev;
48 ngx_buf_t *file; 39 ngx_buf_t *file;
49 ngx_array_t header, trailer; 40 ngx_array_t header, trailer;
50 ngx_event_t *wev; 41 ngx_event_t *wev;
51 ngx_chain_t *cl; 42 ngx_chain_t *cl;
52 struct sf_hdtr hdtr; 43 struct sf_hdtr hdtr;
53 struct iovec *iov, headers[NGX_HEADERS], trailers[NGX_TRAILERS]; 44 struct iovec *iov;
45 struct iovec headers[NGX_IOVS_PREALLOCATE];
46 struct iovec trailers[NGX_IOVS_PREALLOCATE];
54 47
55 wev = c->write; 48 wev = c->write;
56 49
57 if (!wev->ready) { 50 if (!wev->ready) {
58 return in; 51 return in;
77 70
78 send = 0; 71 send = 0;
79 72
80 header.elts = headers; 73 header.elts = headers;
81 header.size = sizeof(struct iovec); 74 header.size = sizeof(struct iovec);
82 header.nalloc = NGX_HEADERS; 75 header.nalloc = NGX_IOVS_PREALLOCATE;
83 header.pool = c->pool; 76 header.pool = c->pool;
84 77
85 trailer.elts = trailers; 78 trailer.elts = trailers;
86 trailer.size = sizeof(struct iovec); 79 trailer.size = sizeof(struct iovec);
87 trailer.nalloc = NGX_TRAILERS; 80 trailer.nalloc = NGX_IOVS_PREALLOCATE;
88 trailer.pool = c->pool; 81 trailer.pool = c->pool;
89 82
90 for ( ;; ) { 83 for ( ;; ) {
91 file = NULL; 84 file = NULL;
92 file_size = 0; 85 file_size = 0;