Mercurial > hg > nginx-quic
annotate src/core/ngx_output_chain.c @ 5142:afea5259e05c
Upstream: fixed tcp_nodelay with connection upgrade (ticket #325).
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Wed, 27 Mar 2013 15:18:34 +0000 |
parents | d620f497c50f |
children | bcdfc39bf44d |
rev | line source |
---|---|
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
430
diff
changeset
|
1 |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
430
diff
changeset
|
2 /* |
444
42d11f017717
nginx-0.1.0-2004-09-29-20:00:49 import; remove years from copyright
Igor Sysoev <igor@sysoev.ru>
parents:
441
diff
changeset
|
3 * Copyright (C) Igor Sysoev |
4412 | 4 * Copyright (C) Nginx, Inc. |
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
430
diff
changeset
|
5 */ |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
430
diff
changeset
|
6 |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
7 |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
8 #include <ngx_config.h> |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
9 #include <ngx_core.h> |
162
96993d4d5067
nginx-0.0.1-2003-10-28-00:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
160
diff
changeset
|
10 #include <ngx_event.h> |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
11 |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
12 |
469 | 13 #if 0 |
14 #define NGX_SENDFILE_LIMIT 4096 | |
15 #endif | |
16 | |
2316 | 17 /* |
18 * When DIRECTIO is enabled FreeBSD, Solaris, and MacOSX read directly | |
19 * to an application memory from a device if parameters are aligned | |
3053 | 20 * to device sector boundary (512 bytes). They fallback to usual read |
2316 | 21 * operation if the parameters are not aligned. |
22 * Linux allows DIRECTIO only if the parameters are aligned to a filesystem | |
23 * sector boundary, otherwise it returns EINVAL. The sector size is | |
24 * usually 512 bytes, however, on XFS it may be 4096 bytes. | |
25 */ | |
469 | 26 |
27 #define NGX_NONE 1 | |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
28 |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
29 |
467 | 30 static ngx_inline ngx_int_t |
2231
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
31 ngx_output_chain_as_is(ngx_output_chain_ctx_t *ctx, ngx_buf_t *buf); |
469 | 32 static ngx_int_t ngx_output_chain_add_copy(ngx_pool_t *pool, |
499 | 33 ngx_chain_t **chain, ngx_chain_t *in); |
2231
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
34 static ngx_int_t ngx_output_chain_align_file_buf(ngx_output_chain_ctx_t *ctx, |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
35 off_t bsize); |
2230 | 36 static ngx_int_t ngx_output_chain_get_buf(ngx_output_chain_ctx_t *ctx, |
37 off_t bsize); | |
2231
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
38 static ngx_int_t ngx_output_chain_copy_buf(ngx_output_chain_ctx_t *ctx); |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
39 |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
40 |
499 | 41 ngx_int_t |
42 ngx_output_chain(ngx_output_chain_ctx_t *ctx, ngx_chain_t *in) | |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
43 { |
473 | 44 off_t bsize; |
597 | 45 ngx_int_t rc, last; |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
46 ngx_chain_t *cl, *out, **last_out; |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
47 |
455 | 48 if (ctx->in == NULL && ctx->busy == NULL) { |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
49 |
469 | 50 /* |
51 * the short path for the case when the ctx->in and ctx->busy chains | |
52 * are empty, the incoming chain is empty too or has the single buf | |
53 * that does not require the copy | |
54 */ | |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
55 |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
56 if (in == NULL) { |
294
5cfd65b8b0a7
nginx-0.0.3-2004-03-23-09:01:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
57 return ctx->output_filter(ctx->filter_ctx, in); |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
58 } |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
59 |
162
96993d4d5067
nginx-0.0.1-2003-10-28-00:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
160
diff
changeset
|
60 if (in->next == NULL |
469 | 61 #if (NGX_SENDFILE_LIMIT) |
62 && !(in->buf->in_file && in->buf->file_last > NGX_SENDFILE_LIMIT) | |
63 #endif | |
2231
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
64 && ngx_output_chain_as_is(ctx, in->buf)) |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
65 { |
294
5cfd65b8b0a7
nginx-0.0.3-2004-03-23-09:01:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
66 return ctx->output_filter(ctx->filter_ctx, in); |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
67 } |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
68 } |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
69 |
344
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
343
diff
changeset
|
70 /* add the incoming buf to the chain ctx->in */ |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
71 |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
72 if (in) { |
469 | 73 if (ngx_output_chain_add_copy(ctx->pool, &ctx->in, in) == NGX_ERROR) { |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
74 return NGX_ERROR; |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
75 } |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
76 } |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
77 |
164
84036764e215
nginx-0.0.1-2003-10-29-11:30:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
162
diff
changeset
|
78 out = NULL; |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
79 last_out = &out; |
499 | 80 last = NGX_NONE; |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
81 |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
82 for ( ;; ) { |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
83 |
3776
7450029ff51e
file AIO read may be posted inside loop
Igor Sysoev <igor@sysoev.ru>
parents:
3515
diff
changeset
|
84 #if (NGX_HAVE_FILE_AIO) |
7450029ff51e
file AIO read may be posted inside loop
Igor Sysoev <igor@sysoev.ru>
parents:
3515
diff
changeset
|
85 if (ctx->aio) { |
7450029ff51e
file AIO read may be posted inside loop
Igor Sysoev <igor@sysoev.ru>
parents:
3515
diff
changeset
|
86 return NGX_AGAIN; |
7450029ff51e
file AIO read may be posted inside loop
Igor Sysoev <igor@sysoev.ru>
parents:
3515
diff
changeset
|
87 } |
7450029ff51e
file AIO read may be posted inside loop
Igor Sysoev <igor@sysoev.ru>
parents:
3515
diff
changeset
|
88 #endif |
7450029ff51e
file AIO read may be posted inside loop
Igor Sysoev <igor@sysoev.ru>
parents:
3515
diff
changeset
|
89 |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
90 while (ctx->in) { |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
91 |
320
d621239c30f7
nginx-0.0.3-2004-04-18-23:06:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
294
diff
changeset
|
92 /* |
343
6bdf858bff8c
nginx-0.0.3-2004-05-28-19:49:23 import; rename ngx_hunk_t to ngx_buf_t
Igor Sysoev <igor@sysoev.ru>
parents:
334
diff
changeset
|
93 * cycle while there are the ctx->in bufs |
2231
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
94 * and there are the free output bufs to copy in |
320
d621239c30f7
nginx-0.0.3-2004-04-18-23:06:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
294
diff
changeset
|
95 */ |
d621239c30f7
nginx-0.0.3-2004-04-18-23:06:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
294
diff
changeset
|
96 |
403
ea3113b181d1
nginx-0.0.9-2004-07-28-23:21:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
402
diff
changeset
|
97 bsize = ngx_buf_size(ctx->in->buf); |
ea3113b181d1
nginx-0.0.9-2004-07-28-23:21:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
402
diff
changeset
|
98 |
ea3113b181d1
nginx-0.0.9-2004-07-28-23:21:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
402
diff
changeset
|
99 if (bsize == 0 && !ngx_buf_special(ctx->in->buf)) { |
ea3113b181d1
nginx-0.0.9-2004-07-28-23:21:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
402
diff
changeset
|
100 |
ea3113b181d1
nginx-0.0.9-2004-07-28-23:21:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
402
diff
changeset
|
101 ngx_log_error(NGX_LOG_ALERT, ctx->pool->log, 0, |
483 | 102 "zero size buf in output " |
103 "t:%d r:%d f:%d %p %p-%p %p %O-%O", | |
104 ctx->in->buf->temporary, | |
105 ctx->in->buf->recycled, | |
106 ctx->in->buf->in_file, | |
107 ctx->in->buf->start, | |
108 ctx->in->buf->pos, | |
109 ctx->in->buf->last, | |
110 ctx->in->buf->file, | |
111 ctx->in->buf->file_pos, | |
112 ctx->in->buf->file_last); | |
403
ea3113b181d1
nginx-0.0.9-2004-07-28-23:21:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
402
diff
changeset
|
113 |
473 | 114 ngx_debug_point(); |
115 | |
403
ea3113b181d1
nginx-0.0.9-2004-07-28-23:21:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
402
diff
changeset
|
116 ctx->in = ctx->in->next; |
430
1fa5daf7558e
nginx-0.0.11-2004-09-19-22:27:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
117 |
403
ea3113b181d1
nginx-0.0.9-2004-07-28-23:21:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
402
diff
changeset
|
118 continue; |
ea3113b181d1
nginx-0.0.9-2004-07-28-23:21:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
402
diff
changeset
|
119 } |
ea3113b181d1
nginx-0.0.9-2004-07-28-23:21:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
402
diff
changeset
|
120 |
2231
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
121 if (ngx_output_chain_as_is(ctx, ctx->in->buf)) { |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
122 |
320
d621239c30f7
nginx-0.0.3-2004-04-18-23:06:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
294
diff
changeset
|
123 /* move the chain link to the output chain */ |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
124 |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
125 cl = ctx->in; |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
126 ctx->in = cl->next; |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
127 |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
128 *last_out = cl; |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
129 last_out = &cl->next; |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
130 cl->next = NULL; |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
131 |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
132 continue; |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
133 } |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
134 |
343
6bdf858bff8c
nginx-0.0.3-2004-05-28-19:49:23 import; rename ngx_hunk_t to ngx_buf_t
Igor Sysoev <igor@sysoev.ru>
parents:
334
diff
changeset
|
135 if (ctx->buf == NULL) { |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
136 |
2231
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
137 rc = ngx_output_chain_align_file_buf(ctx, bsize); |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
138 |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
139 if (rc == NGX_ERROR) { |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
140 return NGX_ERROR; |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
141 } |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
142 |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
143 if (rc != NGX_OK) { |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
144 |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
145 if (ctx->free) { |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
146 |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
147 /* get the free buf */ |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
148 |
2231
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
149 cl = ctx->free; |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
150 ctx->buf = cl->buf; |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
151 ctx->free = cl->next; |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
152 |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
153 ngx_free_chain(ctx->pool, cl); |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
154 |
2231
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
155 } else if (out || ctx->allocated == ctx->bufs.num) { |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
156 |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
157 break; |
334
af451db3fe99
nginx-0.0.3-2004-05-12-09:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
320
diff
changeset
|
158 |
2231
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
159 } else if (ngx_output_chain_get_buf(ctx, bsize) != NGX_OK) { |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
160 return NGX_ERROR; |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
161 } |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
162 } |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
163 } |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
164 |
2231
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
165 rc = ngx_output_chain_copy_buf(ctx); |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
166 |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
167 if (rc == NGX_ERROR) { |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
168 return rc; |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
169 } |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
170 |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
171 if (rc == NGX_AGAIN) { |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
172 if (out) { |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
173 break; |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
174 } |
430
1fa5daf7558e
nginx-0.0.11-2004-09-19-22:27:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
175 |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
176 return rc; |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
177 } |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
178 |
343
6bdf858bff8c
nginx-0.0.3-2004-05-28-19:49:23 import; rename ngx_hunk_t to ngx_buf_t
Igor Sysoev <igor@sysoev.ru>
parents:
334
diff
changeset
|
179 /* delete the completed buf from the ctx->in chain */ |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
180 |
343
6bdf858bff8c
nginx-0.0.3-2004-05-28-19:49:23 import; rename ngx_hunk_t to ngx_buf_t
Igor Sysoev <igor@sysoev.ru>
parents:
334
diff
changeset
|
181 if (ngx_buf_size(ctx->in->buf) == 0) { |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
182 ctx->in = ctx->in->next; |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
183 } |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
184 |
501 | 185 cl = ngx_alloc_chain_link(ctx->pool); |
186 if (cl == NULL) { | |
461 | 187 return NGX_ERROR; |
188 } | |
501 | 189 |
461 | 190 cl->buf = ctx->buf; |
191 cl->next = NULL; | |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
192 *last_out = cl; |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
193 last_out = &cl->next; |
343
6bdf858bff8c
nginx-0.0.3-2004-05-28-19:49:23 import; rename ngx_hunk_t to ngx_buf_t
Igor Sysoev <igor@sysoev.ru>
parents:
334
diff
changeset
|
194 ctx->buf = NULL; |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
195 } |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
196 |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
197 if (out == NULL && last != NGX_NONE) { |
509 | 198 |
199 if (ctx->in) { | |
200 return NGX_AGAIN; | |
201 } | |
202 | |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
203 return last; |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
204 } |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
205 |
294
5cfd65b8b0a7
nginx-0.0.3-2004-03-23-09:01:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
206 last = ctx->output_filter(ctx->filter_ctx, out); |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
207 |
569 | 208 if (last == NGX_ERROR || last == NGX_DONE) { |
209 return last; | |
210 } | |
211 | |
4114
5db098f97e0e
API change: ngx_chain_update_chains() now requires pool.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3776
diff
changeset
|
212 ngx_chain_update_chains(ctx->pool, &ctx->free, &ctx->busy, &out, |
5db098f97e0e
API change: ngx_chain_update_chains() now requires pool.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3776
diff
changeset
|
213 ctx->tag); |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
214 last_out = &out; |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
215 } |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
216 } |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
217 |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
218 |
467 | 219 static ngx_inline ngx_int_t |
2231
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
220 ngx_output_chain_as_is(ngx_output_chain_ctx_t *ctx, ngx_buf_t *buf) |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
221 { |
469 | 222 ngx_uint_t sendfile; |
223 | |
343
6bdf858bff8c
nginx-0.0.3-2004-05-28-19:49:23 import; rename ngx_hunk_t to ngx_buf_t
Igor Sysoev <igor@sysoev.ru>
parents:
334
diff
changeset
|
224 if (ngx_buf_special(buf)) { |
2231
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
225 return 1; |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
226 } |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
227 |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
228 if (buf->in_file && buf->file->directio) { |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
229 return 0; |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
230 } |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
231 |
469 | 232 sendfile = ctx->sendfile; |
233 | |
234 #if (NGX_SENDFILE_LIMIT) | |
235 | |
236 if (buf->in_file && buf->file_pos >= NGX_SENDFILE_LIMIT) { | |
237 sendfile = 0; | |
238 } | |
239 | |
240 #endif | |
241 | |
242 if (!sendfile) { | |
455 | 243 |
343
6bdf858bff8c
nginx-0.0.3-2004-05-28-19:49:23 import; rename ngx_hunk_t to ngx_buf_t
Igor Sysoev <igor@sysoev.ru>
parents:
334
diff
changeset
|
244 if (!ngx_buf_in_memory(buf)) { |
2231
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
245 return 0; |
170
c42be4185301
nginx-0.0.1-2003-11-03-01:56:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
167
diff
changeset
|
246 } |
c42be4185301
nginx-0.0.1-2003-11-03-01:56:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
167
diff
changeset
|
247 |
343
6bdf858bff8c
nginx-0.0.3-2004-05-28-19:49:23 import; rename ngx_hunk_t to ngx_buf_t
Igor Sysoev <igor@sysoev.ru>
parents:
334
diff
changeset
|
248 buf->in_file = 0; |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
249 } |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
250 |
343
6bdf858bff8c
nginx-0.0.3-2004-05-28-19:49:23 import; rename ngx_hunk_t to ngx_buf_t
Igor Sysoev <igor@sysoev.ru>
parents:
334
diff
changeset
|
251 if (ctx->need_in_memory && !ngx_buf_in_memory(buf)) { |
2231
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
252 return 0; |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
253 } |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
254 |
343
6bdf858bff8c
nginx-0.0.3-2004-05-28-19:49:23 import; rename ngx_hunk_t to ngx_buf_t
Igor Sysoev <igor@sysoev.ru>
parents:
334
diff
changeset
|
255 if (ctx->need_in_temp && (buf->memory || buf->mmap)) { |
2231
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
256 return 0; |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
257 } |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
258 |
2231
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
259 return 1; |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
260 } |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
261 |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
262 |
499 | 263 static ngx_int_t |
264 ngx_output_chain_add_copy(ngx_pool_t *pool, ngx_chain_t **chain, | |
265 ngx_chain_t *in) | |
469 | 266 { |
267 ngx_chain_t *cl, **ll; | |
268 #if (NGX_SENDFILE_LIMIT) | |
269 ngx_buf_t *b, *buf; | |
270 #endif | |
271 | |
272 ll = chain; | |
273 | |
274 for (cl = *chain; cl; cl = cl->next) { | |
275 ll = &cl->next; | |
276 } | |
277 | |
278 while (in) { | |
279 | |
501 | 280 cl = ngx_alloc_chain_link(pool); |
281 if (cl == NULL) { | |
469 | 282 return NGX_ERROR; |
283 } | |
284 | |
285 #if (NGX_SENDFILE_LIMIT) | |
286 | |
287 buf = in->buf; | |
288 | |
289 if (buf->in_file | |
290 && buf->file_pos < NGX_SENDFILE_LIMIT | |
291 && buf->file_last > NGX_SENDFILE_LIMIT) | |
292 { | |
2231
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
293 /* split a file buf on two bufs by the sendfile limit */ |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
294 |
501 | 295 b = ngx_calloc_buf(pool); |
296 if (b == NULL) { | |
469 | 297 return NGX_ERROR; |
298 } | |
299 | |
300 ngx_memcpy(b, buf, sizeof(ngx_buf_t)); | |
301 | |
302 if (ngx_buf_in_memory(buf)) { | |
303 buf->pos += (ssize_t) (NGX_SENDFILE_LIMIT - buf->file_pos); | |
304 b->last = buf->pos; | |
305 } | |
306 | |
307 buf->file_pos = NGX_SENDFILE_LIMIT; | |
308 b->file_last = NGX_SENDFILE_LIMIT; | |
309 | |
310 cl->buf = b; | |
311 | |
312 } else { | |
313 cl->buf = buf; | |
314 in = in->next; | |
315 } | |
316 | |
317 #else | |
318 cl->buf = in->buf; | |
319 in = in->next; | |
320 | |
321 #endif | |
322 | |
2910
dc01b26f8de8
leave chain in consistent state on errors
Igor Sysoev <igor@sysoev.ru>
parents:
2899
diff
changeset
|
323 cl->next = NULL; |
469 | 324 *ll = cl; |
325 ll = &cl->next; | |
326 } | |
327 | |
328 return NGX_OK; | |
329 } | |
330 | |
331 | |
499 | 332 static ngx_int_t |
2231
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
333 ngx_output_chain_align_file_buf(ngx_output_chain_ctx_t *ctx, off_t bsize) |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
334 { |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
335 size_t size; |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
336 ngx_buf_t *in; |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
337 |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
338 in = ctx->in->buf; |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
339 |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
340 if (in->file == NULL || !in->file->directio) { |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
341 return NGX_DECLINED; |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
342 } |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
343 |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
344 ctx->directio = 1; |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
345 |
3053 | 346 size = (size_t) (in->file_pos - (in->file_pos & ~(ctx->alignment - 1))); |
2231
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
347 |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
348 if (size == 0) { |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
349 |
2240
a83218b65245
fix building on 64-bit platforms, introduced in r2232
Igor Sysoev <igor@sysoev.ru>
parents:
2231
diff
changeset
|
350 if (bsize >= (off_t) ctx->bufs.size) { |
2231
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
351 return NGX_DECLINED; |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
352 } |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
353 |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
354 size = (size_t) bsize; |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
355 |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
356 } else { |
3057
5ea5a90000d5
fix build by msvc, introduced in r3054
Igor Sysoev <igor@sysoev.ru>
parents:
3053
diff
changeset
|
357 size = (size_t) ctx->alignment - size; |
2231
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
358 |
2240
a83218b65245
fix building on 64-bit platforms, introduced in r2232
Igor Sysoev <igor@sysoev.ru>
parents:
2231
diff
changeset
|
359 if ((off_t) size > bsize) { |
2231
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
360 size = (size_t) bsize; |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
361 } |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
362 } |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
363 |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
364 ctx->buf = ngx_create_temp_buf(ctx->pool, size); |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
365 if (ctx->buf == NULL) { |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
366 return NGX_ERROR; |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
367 } |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
368 |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
369 /* |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
370 * we do not set ctx->buf->tag, because we do not want |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
371 * to reuse the buf via ctx->free list |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
372 */ |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
373 |
2248
1adec90a0e46
disable directio for unaligned reads in Linux
Igor Sysoev <igor@sysoev.ru>
parents:
2245
diff
changeset
|
374 #if (NGX_HAVE_ALIGNED_DIRECTIO) |
1adec90a0e46
disable directio for unaligned reads in Linux
Igor Sysoev <igor@sysoev.ru>
parents:
2245
diff
changeset
|
375 ctx->unaligned = 1; |
1adec90a0e46
disable directio for unaligned reads in Linux
Igor Sysoev <igor@sysoev.ru>
parents:
2245
diff
changeset
|
376 #endif |
1adec90a0e46
disable directio for unaligned reads in Linux
Igor Sysoev <igor@sysoev.ru>
parents:
2245
diff
changeset
|
377 |
2231
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
378 return NGX_OK; |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
379 } |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
380 |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
381 |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
382 static ngx_int_t |
2230 | 383 ngx_output_chain_get_buf(ngx_output_chain_ctx_t *ctx, off_t bsize) |
384 { | |
385 size_t size; | |
2231
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
386 ngx_buf_t *b, *in; |
2230 | 387 ngx_uint_t recycled; |
388 | |
2231
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
389 in = ctx->in->buf; |
2230 | 390 size = ctx->bufs.size; |
391 recycled = 1; | |
392 | |
2231
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
393 if (in->last_in_chain) { |
2230 | 394 |
395 if (bsize < (off_t) size) { | |
396 | |
2231
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
397 /* |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
398 * allocate a small temp buf for a small last buf |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
399 * or its small last part |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
400 */ |
2230 | 401 |
402 size = (size_t) bsize; | |
403 recycled = 0; | |
404 | |
2231
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
405 } else if (!ctx->directio |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
406 && ctx->bufs.num == 1 |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
407 && (bsize < (off_t) (size + size / 4))) |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
408 { |
2230 | 409 /* |
2231
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
410 * allocate a temp buf that equals to a last buf, |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
411 * if there is no directio, the last buf size is lesser |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
412 * than 1.25 of bufs.size and the temp buf is single |
2230 | 413 */ |
414 | |
415 size = (size_t) bsize; | |
416 recycled = 0; | |
417 } | |
418 } | |
419 | |
420 b = ngx_calloc_buf(ctx->pool); | |
421 if (b == NULL) { | |
422 return NGX_ERROR; | |
423 } | |
424 | |
2231
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
425 if (ctx->directio) { |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
426 |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
427 /* |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
428 * allocate block aligned to a disk sector size to enable |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
429 * userland buffer direct usage conjunctly with directio |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
430 */ |
2230 | 431 |
3057
5ea5a90000d5
fix build by msvc, introduced in r3054
Igor Sysoev <igor@sysoev.ru>
parents:
3053
diff
changeset
|
432 b->start = ngx_pmemalign(ctx->pool, size, (size_t) ctx->alignment); |
2231
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
433 if (b->start == NULL) { |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
434 return NGX_ERROR; |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
435 } |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
436 |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
437 } else { |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
438 b->start = ngx_palloc(ctx->pool, size); |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
439 if (b->start == NULL) { |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
440 return NGX_ERROR; |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
441 } |
2230 | 442 } |
443 | |
444 b->pos = b->start; | |
445 b->last = b->start; | |
446 b->end = b->last + size; | |
447 b->temporary = 1; | |
448 b->tag = ctx->tag; | |
449 b->recycled = recycled; | |
450 | |
451 ctx->buf = b; | |
452 ctx->allocated++; | |
453 | |
454 return NGX_OK; | |
455 } | |
456 | |
457 | |
458 static ngx_int_t | |
2231
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
459 ngx_output_chain_copy_buf(ngx_output_chain_ctx_t *ctx) |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
460 { |
2231
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
461 off_t size; |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
462 ssize_t n; |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
463 ngx_buf_t *src, *dst; |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
464 ngx_uint_t sendfile; |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
465 |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
466 src = ctx->in->buf; |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
467 dst = ctx->buf; |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
468 |
343
6bdf858bff8c
nginx-0.0.3-2004-05-28-19:49:23 import; rename ngx_hunk_t to ngx_buf_t
Igor Sysoev <igor@sysoev.ru>
parents:
334
diff
changeset
|
469 size = ngx_buf_size(src); |
3515 | 470 size = ngx_min(size, dst->end - dst->pos); |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
471 |
2231
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
472 sendfile = ctx->sendfile & !ctx->directio; |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
473 |
469 | 474 #if (NGX_SENDFILE_LIMIT) |
475 | |
476 if (src->in_file && src->file_pos >= NGX_SENDFILE_LIMIT) { | |
477 sendfile = 0; | |
478 } | |
479 | |
480 #endif | |
481 | |
343
6bdf858bff8c
nginx-0.0.3-2004-05-28-19:49:23 import; rename ngx_hunk_t to ngx_buf_t
Igor Sysoev <igor@sysoev.ru>
parents:
334
diff
changeset
|
482 if (ngx_buf_in_memory(src)) { |
473 | 483 ngx_memcpy(dst->pos, src->pos, (size_t) size); |
484 src->pos += (size_t) size; | |
485 dst->last += (size_t) size; | |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
486 |
455 | 487 if (src->in_file) { |
488 | |
489 if (sendfile) { | |
490 dst->in_file = 1; | |
491 dst->file = src->file; | |
492 dst->file_pos = src->file_pos; | |
493 dst->file_last = src->file_pos + size; | |
494 | |
495 } else { | |
496 dst->in_file = 0; | |
497 } | |
498 | |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
499 src->file_pos += size; |
452 | 500 |
501 } else { | |
502 dst->in_file = 0; | |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
503 } |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
504 |
1227
3e40f3e4376c
inherit flush flag, this fixes https proxying
Igor Sysoev <igor@sysoev.ru>
parents:
1226
diff
changeset
|
505 if (src->pos == src->last) { |
3e40f3e4376c
inherit flush flag, this fixes https proxying
Igor Sysoev <igor@sysoev.ru>
parents:
1226
diff
changeset
|
506 dst->flush = src->flush; |
3e40f3e4376c
inherit flush flag, this fixes https proxying
Igor Sysoev <igor@sysoev.ru>
parents:
1226
diff
changeset
|
507 dst->last_buf = src->last_buf; |
2899
61d5b945730a
fix XSLT filter in SSI subrequests
Igor Sysoev <igor@sysoev.ru>
parents:
2316
diff
changeset
|
508 dst->last_in_chain = src->last_in_chain; |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
509 } |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
510 |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
511 } else { |
2248
1adec90a0e46
disable directio for unaligned reads in Linux
Igor Sysoev <igor@sysoev.ru>
parents:
2245
diff
changeset
|
512 |
1adec90a0e46
disable directio for unaligned reads in Linux
Igor Sysoev <igor@sysoev.ru>
parents:
2245
diff
changeset
|
513 #if (NGX_HAVE_ALIGNED_DIRECTIO) |
1adec90a0e46
disable directio for unaligned reads in Linux
Igor Sysoev <igor@sysoev.ru>
parents:
2245
diff
changeset
|
514 |
1adec90a0e46
disable directio for unaligned reads in Linux
Igor Sysoev <igor@sysoev.ru>
parents:
2245
diff
changeset
|
515 if (ctx->unaligned) { |
3164
b1b1775698d5
uniform ngx_directio_on/off() interface with other file functions
Igor Sysoev <igor@sysoev.ru>
parents:
3147
diff
changeset
|
516 if (ngx_directio_off(src->file->fd) == NGX_FILE_ERROR) { |
2248
1adec90a0e46
disable directio for unaligned reads in Linux
Igor Sysoev <igor@sysoev.ru>
parents:
2245
diff
changeset
|
517 ngx_log_error(NGX_LOG_ALERT, ctx->pool->log, ngx_errno, |
1adec90a0e46
disable directio for unaligned reads in Linux
Igor Sysoev <igor@sysoev.ru>
parents:
2245
diff
changeset
|
518 ngx_directio_off_n " \"%s\" failed", |
1adec90a0e46
disable directio for unaligned reads in Linux
Igor Sysoev <igor@sysoev.ru>
parents:
2245
diff
changeset
|
519 src->file->name.data); |
1adec90a0e46
disable directio for unaligned reads in Linux
Igor Sysoev <igor@sysoev.ru>
parents:
2245
diff
changeset
|
520 } |
1adec90a0e46
disable directio for unaligned reads in Linux
Igor Sysoev <igor@sysoev.ru>
parents:
2245
diff
changeset
|
521 } |
1adec90a0e46
disable directio for unaligned reads in Linux
Igor Sysoev <igor@sysoev.ru>
parents:
2245
diff
changeset
|
522 |
1adec90a0e46
disable directio for unaligned reads in Linux
Igor Sysoev <igor@sysoev.ru>
parents:
2245
diff
changeset
|
523 #endif |
1adec90a0e46
disable directio for unaligned reads in Linux
Igor Sysoev <igor@sysoev.ru>
parents:
2245
diff
changeset
|
524 |
3052
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
2910
diff
changeset
|
525 #if (NGX_HAVE_FILE_AIO) |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
2910
diff
changeset
|
526 |
3119
4c90c9129a82
fix case when the output filter should add incoming buffers
Igor Sysoev <igor@sysoev.ru>
parents:
3057
diff
changeset
|
527 if (ctx->aio_handler) { |
3052
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
2910
diff
changeset
|
528 n = ngx_file_aio_read(src->file, dst->pos, (size_t) size, |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
2910
diff
changeset
|
529 src->file_pos, ctx->pool); |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
2910
diff
changeset
|
530 if (n == NGX_AGAIN) { |
3119
4c90c9129a82
fix case when the output filter should add incoming buffers
Igor Sysoev <igor@sysoev.ru>
parents:
3057
diff
changeset
|
531 ctx->aio_handler(ctx, src->file); |
3052
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
2910
diff
changeset
|
532 return NGX_AGAIN; |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
2910
diff
changeset
|
533 } |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
2910
diff
changeset
|
534 |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
2910
diff
changeset
|
535 } else { |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
2910
diff
changeset
|
536 n = ngx_read_file(src->file, dst->pos, (size_t) size, |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
2910
diff
changeset
|
537 src->file_pos); |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
2910
diff
changeset
|
538 } |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
2910
diff
changeset
|
539 #else |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
2910
diff
changeset
|
540 |
473 | 541 n = ngx_read_file(src->file, dst->pos, (size_t) size, src->file_pos); |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
542 |
3052
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
2910
diff
changeset
|
543 #endif |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
2910
diff
changeset
|
544 |
2248
1adec90a0e46
disable directio for unaligned reads in Linux
Igor Sysoev <igor@sysoev.ru>
parents:
2245
diff
changeset
|
545 #if (NGX_HAVE_ALIGNED_DIRECTIO) |
1adec90a0e46
disable directio for unaligned reads in Linux
Igor Sysoev <igor@sysoev.ru>
parents:
2245
diff
changeset
|
546 |
1adec90a0e46
disable directio for unaligned reads in Linux
Igor Sysoev <igor@sysoev.ru>
parents:
2245
diff
changeset
|
547 if (ctx->unaligned) { |
1adec90a0e46
disable directio for unaligned reads in Linux
Igor Sysoev <igor@sysoev.ru>
parents:
2245
diff
changeset
|
548 ngx_err_t err; |
1adec90a0e46
disable directio for unaligned reads in Linux
Igor Sysoev <igor@sysoev.ru>
parents:
2245
diff
changeset
|
549 |
1adec90a0e46
disable directio for unaligned reads in Linux
Igor Sysoev <igor@sysoev.ru>
parents:
2245
diff
changeset
|
550 err = ngx_errno; |
1adec90a0e46
disable directio for unaligned reads in Linux
Igor Sysoev <igor@sysoev.ru>
parents:
2245
diff
changeset
|
551 |
3164
b1b1775698d5
uniform ngx_directio_on/off() interface with other file functions
Igor Sysoev <igor@sysoev.ru>
parents:
3147
diff
changeset
|
552 if (ngx_directio_on(src->file->fd) == NGX_FILE_ERROR) { |
2248
1adec90a0e46
disable directio for unaligned reads in Linux
Igor Sysoev <igor@sysoev.ru>
parents:
2245
diff
changeset
|
553 ngx_log_error(NGX_LOG_ALERT, ctx->pool->log, ngx_errno, |
1adec90a0e46
disable directio for unaligned reads in Linux
Igor Sysoev <igor@sysoev.ru>
parents:
2245
diff
changeset
|
554 ngx_directio_on_n " \"%s\" failed", |
1adec90a0e46
disable directio for unaligned reads in Linux
Igor Sysoev <igor@sysoev.ru>
parents:
2245
diff
changeset
|
555 src->file->name.data); |
1adec90a0e46
disable directio for unaligned reads in Linux
Igor Sysoev <igor@sysoev.ru>
parents:
2245
diff
changeset
|
556 } |
1adec90a0e46
disable directio for unaligned reads in Linux
Igor Sysoev <igor@sysoev.ru>
parents:
2245
diff
changeset
|
557 |
1adec90a0e46
disable directio for unaligned reads in Linux
Igor Sysoev <igor@sysoev.ru>
parents:
2245
diff
changeset
|
558 ngx_set_errno(err); |
1adec90a0e46
disable directio for unaligned reads in Linux
Igor Sysoev <igor@sysoev.ru>
parents:
2245
diff
changeset
|
559 |
1adec90a0e46
disable directio for unaligned reads in Linux
Igor Sysoev <igor@sysoev.ru>
parents:
2245
diff
changeset
|
560 ctx->unaligned = 0; |
1adec90a0e46
disable directio for unaligned reads in Linux
Igor Sysoev <igor@sysoev.ru>
parents:
2245
diff
changeset
|
561 } |
1adec90a0e46
disable directio for unaligned reads in Linux
Igor Sysoev <igor@sysoev.ru>
parents:
2245
diff
changeset
|
562 |
1adec90a0e46
disable directio for unaligned reads in Linux
Igor Sysoev <igor@sysoev.ru>
parents:
2245
diff
changeset
|
563 #endif |
1adec90a0e46
disable directio for unaligned reads in Linux
Igor Sysoev <igor@sysoev.ru>
parents:
2245
diff
changeset
|
564 |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
565 if (n == NGX_ERROR) { |
517 | 566 return (ngx_int_t) n; |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
567 } |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
568 |
473 | 569 if (n != size) { |
2231
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
570 ngx_log_error(NGX_LOG_ALERT, ctx->pool->log, 0, |
2245
8a98616abb73
add filename to the log message
Igor Sysoev <igor@sysoev.ru>
parents:
2240
diff
changeset
|
571 ngx_read_file_n " read only %z of %O from \"%s\"", |
8a98616abb73
add filename to the log message
Igor Sysoev <igor@sysoev.ru>
parents:
2240
diff
changeset
|
572 n, size, src->file->name.data); |
3147
cbb1add4a6fe
fail if file size was changed
Igor Sysoev <igor@sysoev.ru>
parents:
3119
diff
changeset
|
573 return NGX_ERROR; |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
574 } |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
575 |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
576 dst->last += n; |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
577 |
452 | 578 if (sendfile) { |
579 dst->in_file = 1; | |
580 dst->file = src->file; | |
581 dst->file_pos = src->file_pos; | |
455 | 582 dst->file_last = src->file_pos + n; |
452 | 583 |
584 } else { | |
343
6bdf858bff8c
nginx-0.0.3-2004-05-28-19:49:23 import; rename ngx_hunk_t to ngx_buf_t
Igor Sysoev <igor@sysoev.ru>
parents:
334
diff
changeset
|
585 dst->in_file = 0; |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
586 } |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
587 |
455 | 588 src->file_pos += n; |
589 | |
1238 | 590 if (src->file_pos == src->file_last) { |
1227
3e40f3e4376c
inherit flush flag, this fixes https proxying
Igor Sysoev <igor@sysoev.ru>
parents:
1226
diff
changeset
|
591 dst->flush = src->flush; |
3e40f3e4376c
inherit flush flag, this fixes https proxying
Igor Sysoev <igor@sysoev.ru>
parents:
1226
diff
changeset
|
592 dst->last_buf = src->last_buf; |
2899
61d5b945730a
fix XSLT filter in SSI subrequests
Igor Sysoev <igor@sysoev.ru>
parents:
2316
diff
changeset
|
593 dst->last_in_chain = src->last_in_chain; |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
594 } |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
595 } |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
596 |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
597 return NGX_OK; |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
598 } |
162
96993d4d5067
nginx-0.0.1-2003-10-28-00:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
160
diff
changeset
|
599 |
96993d4d5067
nginx-0.0.1-2003-10-28-00:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
160
diff
changeset
|
600 |
499 | 601 ngx_int_t |
602 ngx_chain_writer(void *data, ngx_chain_t *in) | |
162
96993d4d5067
nginx-0.0.1-2003-10-28-00:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
160
diff
changeset
|
603 { |
166
389d7ee9fa60
nginx-0.0.1-2003-10-30-11:51:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
164
diff
changeset
|
604 ngx_chain_writer_ctx_t *ctx = data; |
162
96993d4d5067
nginx-0.0.1-2003-10-28-00:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
160
diff
changeset
|
605 |
1962 | 606 off_t size; |
607 ngx_chain_t *cl; | |
608 ngx_connection_t *c; | |
609 | |
610 c = ctx->connection; | |
162
96993d4d5067
nginx-0.0.1-2003-10-28-00:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
160
diff
changeset
|
611 |
473 | 612 for (size = 0; in; in = in->next) { |
613 | |
614 #if 1 | |
615 if (ngx_buf_size(in->buf) == 0 && !ngx_buf_special(in->buf)) { | |
616 ngx_debug_point(); | |
617 } | |
618 #endif | |
619 | |
620 size += ngx_buf_size(in->buf); | |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
403
diff
changeset
|
621 |
1962 | 622 ngx_log_debug2(NGX_LOG_DEBUG_CORE, c->log, 0, |
1226 | 623 "chain writer buf fl:%d s:%uO", |
624 in->buf->flush, ngx_buf_size(in->buf)); | |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
403
diff
changeset
|
625 |
501 | 626 cl = ngx_alloc_chain_link(ctx->pool); |
627 if (cl == NULL) { | |
461 | 628 return NGX_ERROR; |
629 } | |
501 | 630 |
461 | 631 cl->buf = in->buf; |
632 cl->next = NULL; | |
162
96993d4d5067
nginx-0.0.1-2003-10-28-00:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
160
diff
changeset
|
633 *ctx->last = cl; |
96993d4d5067
nginx-0.0.1-2003-10-28-00:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
160
diff
changeset
|
634 ctx->last = &cl->next; |
96993d4d5067
nginx-0.0.1-2003-10-28-00:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
160
diff
changeset
|
635 } |
96993d4d5067
nginx-0.0.1-2003-10-28-00:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
160
diff
changeset
|
636 |
1962 | 637 ngx_log_debug1(NGX_LOG_DEBUG_CORE, c->log, 0, |
461 | 638 "chain writer in: %p", ctx->out); |
291
117ccc7c4055
nginx-0.0.3-2004-03-16-16:35:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
639 |
473 | 640 for (cl = ctx->out; cl; cl = cl->next) { |
641 | |
642 #if 1 | |
643 if (ngx_buf_size(cl->buf) == 0 && !ngx_buf_special(cl->buf)) { | |
644 ngx_debug_point(); | |
645 } | |
646 | |
647 #endif | |
648 | |
649 size += ngx_buf_size(cl->buf); | |
650 } | |
651 | |
1962 | 652 if (size == 0 && !c->buffered) { |
473 | 653 return NGX_OK; |
654 } | |
655 | |
1962 | 656 ctx->out = c->send_chain(c, ctx->out, ctx->limit); |
162
96993d4d5067
nginx-0.0.1-2003-10-28-00:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
160
diff
changeset
|
657 |
1962 | 658 ngx_log_debug1(NGX_LOG_DEBUG_CORE, c->log, 0, |
461 | 659 "chain writer out: %p", ctx->out); |
291
117ccc7c4055
nginx-0.0.3-2004-03-16-16:35:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
660 |
162
96993d4d5067
nginx-0.0.1-2003-10-28-00:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
160
diff
changeset
|
661 if (ctx->out == NGX_CHAIN_ERROR) { |
96993d4d5067
nginx-0.0.1-2003-10-28-00:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
160
diff
changeset
|
662 return NGX_ERROR; |
96993d4d5067
nginx-0.0.1-2003-10-28-00:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
160
diff
changeset
|
663 } |
96993d4d5067
nginx-0.0.1-2003-10-28-00:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
160
diff
changeset
|
664 |
96993d4d5067
nginx-0.0.1-2003-10-28-00:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
160
diff
changeset
|
665 if (ctx->out == NULL) { |
96993d4d5067
nginx-0.0.1-2003-10-28-00:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
160
diff
changeset
|
666 ctx->last = &ctx->out; |
1211 | 667 |
1962 | 668 if (!c->buffered) { |
1215
fb3ff245c96b
an request body might not be passed to backend,
Igor Sysoev <igor@sysoev.ru>
parents:
1211
diff
changeset
|
669 return NGX_OK; |
fb3ff245c96b
an request body might not be passed to backend,
Igor Sysoev <igor@sysoev.ru>
parents:
1211
diff
changeset
|
670 } |
162
96993d4d5067
nginx-0.0.1-2003-10-28-00:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
160
diff
changeset
|
671 } |
96993d4d5067
nginx-0.0.1-2003-10-28-00:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
160
diff
changeset
|
672 |
96993d4d5067
nginx-0.0.1-2003-10-28-00:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
160
diff
changeset
|
673 return NGX_AGAIN; |
96993d4d5067
nginx-0.0.1-2003-10-28-00:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
160
diff
changeset
|
674 } |