Mercurial > hg > nginx-quic
annotate src/core/ngx_output_chain.c @ 8862:c2f5d79cde64 quic
QUIC: separate UDP framework for QUIC.
Previously, QUIC used the existing UDP framework, which was created for UDP in
Stream. However the way QUIC connections are created and looked up is different
from the way UDP connections in Stream are created and looked up. Now these
two implementations are decoupled.
author | Roman Arutyunyan <arut@nginx.com> |
---|---|
date | Wed, 20 Apr 2022 16:01:17 +0400 |
parents | b002ad258f1d |
children |
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 |
5966
bcdfc39bf44d
Fixed AIO handling in the output chain.
Valentin Bartenev <vbart@nginx.com>
parents:
4412
diff
changeset
|
48 if (ctx->in == NULL && ctx->busy == NULL |
6022
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5980
diff
changeset
|
49 #if (NGX_HAVE_FILE_AIO || NGX_THREADS) |
5966
bcdfc39bf44d
Fixed AIO handling in the output chain.
Valentin Bartenev <vbart@nginx.com>
parents:
4412
diff
changeset
|
50 && !ctx->aio |
bcdfc39bf44d
Fixed AIO handling in the output chain.
Valentin Bartenev <vbart@nginx.com>
parents:
4412
diff
changeset
|
51 #endif |
bcdfc39bf44d
Fixed AIO handling in the output chain.
Valentin Bartenev <vbart@nginx.com>
parents:
4412
diff
changeset
|
52 ) |
bcdfc39bf44d
Fixed AIO handling in the output chain.
Valentin Bartenev <vbart@nginx.com>
parents:
4412
diff
changeset
|
53 { |
469 | 54 /* |
55 * the short path for the case when the ctx->in and ctx->busy chains | |
56 * are empty, the incoming chain is empty too or has the single buf | |
57 * that does not require the copy | |
58 */ | |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
59 |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
60 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
|
61 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
|
62 } |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
63 |
162
96993d4d5067
nginx-0.0.1-2003-10-28-00:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
160
diff
changeset
|
64 if (in->next == NULL |
469 | 65 #if (NGX_SENDFILE_LIMIT) |
66 && !(in->buf->in_file && in->buf->file_last > NGX_SENDFILE_LIMIT) | |
67 #endif | |
2231
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
68 && 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
|
69 { |
294
5cfd65b8b0a7
nginx-0.0.3-2004-03-23-09:01:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
70 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
|
71 } |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
72 } |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
73 |
344
e366ba5db8f8
nginx-0.0.3-2004-06-01-10:04:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
343
diff
changeset
|
74 /* 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
|
75 |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
76 if (in) { |
469 | 77 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
|
78 return NGX_ERROR; |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
79 } |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
80 } |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
81 |
164
84036764e215
nginx-0.0.1-2003-10-29-11:30:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
162
diff
changeset
|
82 out = NULL; |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
83 last_out = &out; |
499 | 84 last = NGX_NONE; |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
85 |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
86 for ( ;; ) { |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
87 |
6022
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5980
diff
changeset
|
88 #if (NGX_HAVE_FILE_AIO || NGX_THREADS) |
3776
7450029ff51e
file AIO read may be posted inside loop
Igor Sysoev <igor@sysoev.ru>
parents:
3515
diff
changeset
|
89 if (ctx->aio) { |
7450029ff51e
file AIO read may be posted inside loop
Igor Sysoev <igor@sysoev.ru>
parents:
3515
diff
changeset
|
90 return NGX_AGAIN; |
7450029ff51e
file AIO read may be posted inside loop
Igor Sysoev <igor@sysoev.ru>
parents:
3515
diff
changeset
|
91 } |
7450029ff51e
file AIO read may be posted inside loop
Igor Sysoev <igor@sysoev.ru>
parents:
3515
diff
changeset
|
92 #endif |
7450029ff51e
file AIO read may be posted inside loop
Igor Sysoev <igor@sysoev.ru>
parents:
3515
diff
changeset
|
93 |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
94 while (ctx->in) { |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
95 |
320
d621239c30f7
nginx-0.0.3-2004-04-18-23:06:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
294
diff
changeset
|
96 /* |
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
|
97 * 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
|
98 * 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
|
99 */ |
d621239c30f7
nginx-0.0.3-2004-04-18-23:06:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
294
diff
changeset
|
100 |
403
ea3113b181d1
nginx-0.0.9-2004-07-28-23:21:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
402
diff
changeset
|
101 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
|
102 |
ea3113b181d1
nginx-0.0.9-2004-07-28-23:21:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
402
diff
changeset
|
103 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
|
104 |
ea3113b181d1
nginx-0.0.9-2004-07-28-23:21:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
402
diff
changeset
|
105 ngx_log_error(NGX_LOG_ALERT, ctx->pool->log, 0, |
483 | 106 "zero size buf in output " |
107 "t:%d r:%d f:%d %p %p-%p %p %O-%O", | |
108 ctx->in->buf->temporary, | |
109 ctx->in->buf->recycled, | |
110 ctx->in->buf->in_file, | |
111 ctx->in->buf->start, | |
112 ctx->in->buf->pos, | |
113 ctx->in->buf->last, | |
114 ctx->in->buf->file, | |
115 ctx->in->buf->file_pos, | |
116 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
|
117 |
473 | 118 ngx_debug_point(); |
119 | |
403
ea3113b181d1
nginx-0.0.9-2004-07-28-23:21:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
402
diff
changeset
|
120 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
|
121 |
403
ea3113b181d1
nginx-0.0.9-2004-07-28-23:21:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
402
diff
changeset
|
122 continue; |
ea3113b181d1
nginx-0.0.9-2004-07-28-23:21:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
402
diff
changeset
|
123 } |
ea3113b181d1
nginx-0.0.9-2004-07-28-23:21:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
402
diff
changeset
|
124 |
7401
a7ff19afbb14
Negative size buffers detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6819
diff
changeset
|
125 if (bsize < 0) { |
a7ff19afbb14
Negative size buffers detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6819
diff
changeset
|
126 |
a7ff19afbb14
Negative size buffers detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6819
diff
changeset
|
127 ngx_log_error(NGX_LOG_ALERT, ctx->pool->log, 0, |
a7ff19afbb14
Negative size buffers detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6819
diff
changeset
|
128 "negative size buf in output " |
a7ff19afbb14
Negative size buffers detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6819
diff
changeset
|
129 "t:%d r:%d f:%d %p %p-%p %p %O-%O", |
a7ff19afbb14
Negative size buffers detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6819
diff
changeset
|
130 ctx->in->buf->temporary, |
a7ff19afbb14
Negative size buffers detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6819
diff
changeset
|
131 ctx->in->buf->recycled, |
a7ff19afbb14
Negative size buffers detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6819
diff
changeset
|
132 ctx->in->buf->in_file, |
a7ff19afbb14
Negative size buffers detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6819
diff
changeset
|
133 ctx->in->buf->start, |
a7ff19afbb14
Negative size buffers detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6819
diff
changeset
|
134 ctx->in->buf->pos, |
a7ff19afbb14
Negative size buffers detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6819
diff
changeset
|
135 ctx->in->buf->last, |
a7ff19afbb14
Negative size buffers detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6819
diff
changeset
|
136 ctx->in->buf->file, |
a7ff19afbb14
Negative size buffers detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6819
diff
changeset
|
137 ctx->in->buf->file_pos, |
a7ff19afbb14
Negative size buffers detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6819
diff
changeset
|
138 ctx->in->buf->file_last); |
a7ff19afbb14
Negative size buffers detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6819
diff
changeset
|
139 |
a7ff19afbb14
Negative size buffers detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6819
diff
changeset
|
140 ngx_debug_point(); |
a7ff19afbb14
Negative size buffers detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6819
diff
changeset
|
141 |
a7ff19afbb14
Negative size buffers detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6819
diff
changeset
|
142 return NGX_ERROR; |
a7ff19afbb14
Negative size buffers detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6819
diff
changeset
|
143 } |
a7ff19afbb14
Negative size buffers detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6819
diff
changeset
|
144 |
2231
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
145 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
|
146 |
320
d621239c30f7
nginx-0.0.3-2004-04-18-23:06:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
294
diff
changeset
|
147 /* 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
|
148 |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
149 cl = ctx->in; |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
150 ctx->in = cl->next; |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
151 |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
152 *last_out = cl; |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
153 last_out = &cl->next; |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
154 cl->next = NULL; |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
155 |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
156 continue; |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
157 } |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
158 |
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
|
159 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
|
160 |
2231
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
161 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
|
162 |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
163 if (rc == NGX_ERROR) { |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
164 return NGX_ERROR; |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
165 } |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
166 |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
167 if (rc != NGX_OK) { |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
168 |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
169 if (ctx->free) { |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
170 |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
171 /* 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
|
172 |
2231
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
173 cl = ctx->free; |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
174 ctx->buf = cl->buf; |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
175 ctx->free = cl->next; |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
176 |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
177 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
|
178 |
2231
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
179 } else if (out || ctx->allocated == ctx->bufs.num) { |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
180 |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
181 break; |
334
af451db3fe99
nginx-0.0.3-2004-05-12-09:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
320
diff
changeset
|
182 |
2231
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
183 } 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
|
184 return NGX_ERROR; |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
185 } |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
186 } |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
187 } |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
188 |
2231
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
189 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
|
190 |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
191 if (rc == NGX_ERROR) { |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
192 return rc; |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
193 } |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
194 |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
195 if (rc == NGX_AGAIN) { |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
196 if (out) { |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
197 break; |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
198 } |
430
1fa5daf7558e
nginx-0.0.11-2004-09-19-22:27:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
199 |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
200 return rc; |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
201 } |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
202 |
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
|
203 /* 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
|
204 |
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
|
205 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
|
206 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
|
207 } |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
208 |
501 | 209 cl = ngx_alloc_chain_link(ctx->pool); |
210 if (cl == NULL) { | |
461 | 211 return NGX_ERROR; |
212 } | |
501 | 213 |
461 | 214 cl->buf = ctx->buf; |
215 cl->next = NULL; | |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
216 *last_out = cl; |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
217 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
|
218 ctx->buf = NULL; |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
219 } |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
220 |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
221 if (out == NULL && last != NGX_NONE) { |
509 | 222 |
223 if (ctx->in) { | |
224 return NGX_AGAIN; | |
225 } | |
226 | |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
227 return last; |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
228 } |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
229 |
294
5cfd65b8b0a7
nginx-0.0.3-2004-03-23-09:01:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
230 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
|
231 |
569 | 232 if (last == NGX_ERROR || last == NGX_DONE) { |
233 return last; | |
234 } | |
235 | |
4114
5db098f97e0e
API change: ngx_chain_update_chains() now requires pool.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3776
diff
changeset
|
236 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
|
237 ctx->tag); |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
238 last_out = &out; |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
239 } |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
240 } |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
241 |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
242 |
467 | 243 static ngx_inline ngx_int_t |
2231
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
244 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
|
245 { |
469 | 246 ngx_uint_t sendfile; |
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 if (ngx_buf_special(buf)) { |
2231
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
249 return 1; |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
250 } |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
251 |
6022
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5980
diff
changeset
|
252 #if (NGX_THREADS) |
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5980
diff
changeset
|
253 if (buf->in_file) { |
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5980
diff
changeset
|
254 buf->file->thread_handler = ctx->thread_handler; |
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5980
diff
changeset
|
255 buf->file->thread_ctx = ctx->filter_ctx; |
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5980
diff
changeset
|
256 } |
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5980
diff
changeset
|
257 #endif |
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5980
diff
changeset
|
258 |
469 | 259 sendfile = ctx->sendfile; |
260 | |
261 #if (NGX_SENDFILE_LIMIT) | |
262 | |
263 if (buf->in_file && buf->file_pos >= NGX_SENDFILE_LIMIT) { | |
264 sendfile = 0; | |
265 } | |
266 | |
267 #endif | |
268 | |
8778
b002ad258f1d
Support for sendfile(SF_NOCACHE).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8776
diff
changeset
|
269 #if !(NGX_HAVE_SENDFILE_NODISKIO) |
b002ad258f1d
Support for sendfile(SF_NOCACHE).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8776
diff
changeset
|
270 |
b002ad258f1d
Support for sendfile(SF_NOCACHE).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8776
diff
changeset
|
271 /* |
b002ad258f1d
Support for sendfile(SF_NOCACHE).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8776
diff
changeset
|
272 * With DIRECTIO, disable sendfile() unless sendfile(SF_NOCACHE) |
b002ad258f1d
Support for sendfile(SF_NOCACHE).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8776
diff
changeset
|
273 * is available. |
b002ad258f1d
Support for sendfile(SF_NOCACHE).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8776
diff
changeset
|
274 */ |
b002ad258f1d
Support for sendfile(SF_NOCACHE).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8776
diff
changeset
|
275 |
b002ad258f1d
Support for sendfile(SF_NOCACHE).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8776
diff
changeset
|
276 if (buf->in_file && buf->file->directio) { |
b002ad258f1d
Support for sendfile(SF_NOCACHE).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8776
diff
changeset
|
277 sendfile = 0; |
b002ad258f1d
Support for sendfile(SF_NOCACHE).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8776
diff
changeset
|
278 } |
b002ad258f1d
Support for sendfile(SF_NOCACHE).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8776
diff
changeset
|
279 |
b002ad258f1d
Support for sendfile(SF_NOCACHE).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8776
diff
changeset
|
280 #endif |
b002ad258f1d
Support for sendfile(SF_NOCACHE).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8776
diff
changeset
|
281 |
469 | 282 if (!sendfile) { |
455 | 283 |
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
|
284 if (!ngx_buf_in_memory(buf)) { |
2231
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
285 return 0; |
170
c42be4185301
nginx-0.0.1-2003-11-03-01:56:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
167
diff
changeset
|
286 } |
c42be4185301
nginx-0.0.1-2003-11-03-01:56:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
167
diff
changeset
|
287 |
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
|
288 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
|
289 } |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
290 |
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
|
291 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
|
292 return 0; |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
293 } |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
294 |
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
|
295 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
|
296 return 0; |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
297 } |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
298 |
2231
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
299 return 1; |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
300 } |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
301 |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
302 |
499 | 303 static ngx_int_t |
304 ngx_output_chain_add_copy(ngx_pool_t *pool, ngx_chain_t **chain, | |
305 ngx_chain_t *in) | |
469 | 306 { |
307 ngx_chain_t *cl, **ll; | |
308 #if (NGX_SENDFILE_LIMIT) | |
309 ngx_buf_t *b, *buf; | |
310 #endif | |
311 | |
312 ll = chain; | |
313 | |
314 for (cl = *chain; cl; cl = cl->next) { | |
315 ll = &cl->next; | |
316 } | |
317 | |
318 while (in) { | |
319 | |
501 | 320 cl = ngx_alloc_chain_link(pool); |
321 if (cl == NULL) { | |
469 | 322 return NGX_ERROR; |
323 } | |
324 | |
325 #if (NGX_SENDFILE_LIMIT) | |
326 | |
327 buf = in->buf; | |
328 | |
329 if (buf->in_file | |
330 && buf->file_pos < NGX_SENDFILE_LIMIT | |
331 && buf->file_last > NGX_SENDFILE_LIMIT) | |
332 { | |
2231
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
333 /* 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
|
334 |
501 | 335 b = ngx_calloc_buf(pool); |
336 if (b == NULL) { | |
469 | 337 return NGX_ERROR; |
338 } | |
339 | |
340 ngx_memcpy(b, buf, sizeof(ngx_buf_t)); | |
341 | |
342 if (ngx_buf_in_memory(buf)) { | |
343 buf->pos += (ssize_t) (NGX_SENDFILE_LIMIT - buf->file_pos); | |
344 b->last = buf->pos; | |
345 } | |
346 | |
347 buf->file_pos = NGX_SENDFILE_LIMIT; | |
348 b->file_last = NGX_SENDFILE_LIMIT; | |
349 | |
350 cl->buf = b; | |
351 | |
352 } else { | |
353 cl->buf = buf; | |
354 in = in->next; | |
355 } | |
356 | |
357 #else | |
358 cl->buf = in->buf; | |
359 in = in->next; | |
360 | |
361 #endif | |
362 | |
2910
dc01b26f8de8
leave chain in consistent state on errors
Igor Sysoev <igor@sysoev.ru>
parents:
2899
diff
changeset
|
363 cl->next = NULL; |
469 | 364 *ll = cl; |
365 ll = &cl->next; | |
366 } | |
367 | |
368 return NGX_OK; | |
369 } | |
370 | |
371 | |
499 | 372 static ngx_int_t |
2231
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
373 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
|
374 { |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
375 size_t size; |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
376 ngx_buf_t *in; |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
377 |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
378 in = ctx->in->buf; |
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 if (in->file == NULL || !in->file->directio) { |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
381 return NGX_DECLINED; |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
382 } |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
383 |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
384 ctx->directio = 1; |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
385 |
3053 | 386 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
|
387 |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
388 if (size == 0) { |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
389 |
2240
a83218b65245
fix building on 64-bit platforms, introduced in r2232
Igor Sysoev <igor@sysoev.ru>
parents:
2231
diff
changeset
|
390 if (bsize >= (off_t) ctx->bufs.size) { |
2231
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
391 return NGX_DECLINED; |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
392 } |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
393 |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
394 size = (size_t) bsize; |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
395 |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
396 } else { |
3057
5ea5a90000d5
fix build by msvc, introduced in r3054
Igor Sysoev <igor@sysoev.ru>
parents:
3053
diff
changeset
|
397 size = (size_t) ctx->alignment - size; |
2231
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
398 |
2240
a83218b65245
fix building on 64-bit platforms, introduced in r2232
Igor Sysoev <igor@sysoev.ru>
parents:
2231
diff
changeset
|
399 if ((off_t) size > bsize) { |
2231
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
400 size = (size_t) bsize; |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
401 } |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
402 } |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
403 |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
404 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
|
405 if (ctx->buf == NULL) { |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
406 return NGX_ERROR; |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
407 } |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
408 |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
409 /* |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
410 * 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
|
411 * to reuse the buf via ctx->free list |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
412 */ |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
413 |
2248
1adec90a0e46
disable directio for unaligned reads in Linux
Igor Sysoev <igor@sysoev.ru>
parents:
2245
diff
changeset
|
414 #if (NGX_HAVE_ALIGNED_DIRECTIO) |
1adec90a0e46
disable directio for unaligned reads in Linux
Igor Sysoev <igor@sysoev.ru>
parents:
2245
diff
changeset
|
415 ctx->unaligned = 1; |
1adec90a0e46
disable directio for unaligned reads in Linux
Igor Sysoev <igor@sysoev.ru>
parents:
2245
diff
changeset
|
416 #endif |
1adec90a0e46
disable directio for unaligned reads in Linux
Igor Sysoev <igor@sysoev.ru>
parents:
2245
diff
changeset
|
417 |
2231
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
418 return NGX_OK; |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
419 } |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
420 |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
421 |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
422 static ngx_int_t |
2230 | 423 ngx_output_chain_get_buf(ngx_output_chain_ctx_t *ctx, off_t bsize) |
424 { | |
425 size_t size; | |
2231
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
426 ngx_buf_t *b, *in; |
2230 | 427 ngx_uint_t recycled; |
428 | |
2231
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
429 in = ctx->in->buf; |
2230 | 430 size = ctx->bufs.size; |
431 recycled = 1; | |
432 | |
2231
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
433 if (in->last_in_chain) { |
2230 | 434 |
435 if (bsize < (off_t) size) { | |
436 | |
2231
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
437 /* |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
438 * 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
|
439 * or its small last part |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
440 */ |
2230 | 441 |
442 size = (size_t) bsize; | |
443 recycled = 0; | |
444 | |
2231
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
445 } else if (!ctx->directio |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
446 && ctx->bufs.num == 1 |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
447 && (bsize < (off_t) (size + size / 4))) |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
448 { |
2230 | 449 /* |
2231
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
450 * 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
|
451 * 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
|
452 * than 1.25 of bufs.size and the temp buf is single |
2230 | 453 */ |
454 | |
455 size = (size_t) bsize; | |
456 recycled = 0; | |
457 } | |
458 } | |
459 | |
460 b = ngx_calloc_buf(ctx->pool); | |
461 if (b == NULL) { | |
462 return NGX_ERROR; | |
463 } | |
464 | |
2231
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
465 if (ctx->directio) { |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
466 |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
467 /* |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
468 * 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
|
469 * userland buffer direct usage conjunctly with directio |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
470 */ |
2230 | 471 |
3057
5ea5a90000d5
fix build by msvc, introduced in r3054
Igor Sysoev <igor@sysoev.ru>
parents:
3053
diff
changeset
|
472 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
|
473 if (b->start == NULL) { |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
474 return NGX_ERROR; |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
475 } |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
476 |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
477 } else { |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
478 b->start = ngx_palloc(ctx->pool, size); |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
479 if (b->start == NULL) { |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
480 return NGX_ERROR; |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
481 } |
2230 | 482 } |
483 | |
484 b->pos = b->start; | |
485 b->last = b->start; | |
486 b->end = b->last + size; | |
487 b->temporary = 1; | |
488 b->tag = ctx->tag; | |
489 b->recycled = recycled; | |
490 | |
491 ctx->buf = b; | |
492 ctx->allocated++; | |
493 | |
494 return NGX_OK; | |
495 } | |
496 | |
497 | |
498 static ngx_int_t | |
2231
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
499 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
|
500 { |
2231
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
501 off_t size; |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
502 ssize_t n; |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
503 ngx_buf_t *src, *dst; |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
504 ngx_uint_t sendfile; |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
505 |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
506 src = ctx->in->buf; |
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
507 dst = ctx->buf; |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
508 |
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
|
509 size = ngx_buf_size(src); |
3515 | 510 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
|
511 |
6819
4395758d08e6
Fixed spelling of logical AND operator, no functional changes.
Sergey Kandaurov <pluknet@nginx.com>
parents:
6441
diff
changeset
|
512 sendfile = ctx->sendfile && !ctx->directio; |
2231
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
513 |
469 | 514 #if (NGX_SENDFILE_LIMIT) |
515 | |
516 if (src->in_file && src->file_pos >= NGX_SENDFILE_LIMIT) { | |
517 sendfile = 0; | |
518 } | |
519 | |
520 #endif | |
521 | |
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
|
522 if (ngx_buf_in_memory(src)) { |
473 | 523 ngx_memcpy(dst->pos, src->pos, (size_t) size); |
524 src->pos += (size_t) size; | |
525 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
|
526 |
455 | 527 if (src->in_file) { |
528 | |
529 if (sendfile) { | |
530 dst->in_file = 1; | |
531 dst->file = src->file; | |
532 dst->file_pos = src->file_pos; | |
533 dst->file_last = src->file_pos + size; | |
534 | |
535 } else { | |
536 dst->in_file = 0; | |
537 } | |
538 | |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
539 src->file_pos += size; |
452 | 540 |
541 } else { | |
542 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
|
543 } |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
544 |
1227
3e40f3e4376c
inherit flush flag, this fixes https proxying
Igor Sysoev <igor@sysoev.ru>
parents:
1226
diff
changeset
|
545 if (src->pos == src->last) { |
3e40f3e4376c
inherit flush flag, this fixes https proxying
Igor Sysoev <igor@sysoev.ru>
parents:
1226
diff
changeset
|
546 dst->flush = src->flush; |
3e40f3e4376c
inherit flush flag, this fixes https proxying
Igor Sysoev <igor@sysoev.ru>
parents:
1226
diff
changeset
|
547 dst->last_buf = src->last_buf; |
2899
61d5b945730a
fix XSLT filter in SSI subrequests
Igor Sysoev <igor@sysoev.ru>
parents:
2316
diff
changeset
|
548 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
|
549 } |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
550 |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
551 } else { |
2248
1adec90a0e46
disable directio for unaligned reads in Linux
Igor Sysoev <igor@sysoev.ru>
parents:
2245
diff
changeset
|
552 |
1adec90a0e46
disable directio for unaligned reads in Linux
Igor Sysoev <igor@sysoev.ru>
parents:
2245
diff
changeset
|
553 #if (NGX_HAVE_ALIGNED_DIRECTIO) |
1adec90a0e46
disable directio for unaligned reads in Linux
Igor Sysoev <igor@sysoev.ru>
parents:
2245
diff
changeset
|
554 |
1adec90a0e46
disable directio for unaligned reads in Linux
Igor Sysoev <igor@sysoev.ru>
parents:
2245
diff
changeset
|
555 if (ctx->unaligned) { |
3164
b1b1775698d5
uniform ngx_directio_on/off() interface with other file functions
Igor Sysoev <igor@sysoev.ru>
parents:
3147
diff
changeset
|
556 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
|
557 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
|
558 ngx_directio_off_n " \"%s\" failed", |
1adec90a0e46
disable directio for unaligned reads in Linux
Igor Sysoev <igor@sysoev.ru>
parents:
2245
diff
changeset
|
559 src->file->name.data); |
1adec90a0e46
disable directio for unaligned reads in Linux
Igor Sysoev <igor@sysoev.ru>
parents:
2245
diff
changeset
|
560 } |
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 |
3052
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
2910
diff
changeset
|
565 #if (NGX_HAVE_FILE_AIO) |
3119
4c90c9129a82
fix case when the output filter should add incoming buffers
Igor Sysoev <igor@sysoev.ru>
parents:
3057
diff
changeset
|
566 if (ctx->aio_handler) { |
3052
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
2910
diff
changeset
|
567 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
|
568 src->file_pos, ctx->pool); |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
2910
diff
changeset
|
569 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
|
570 ctx->aio_handler(ctx, src->file); |
3052
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
2910
diff
changeset
|
571 return NGX_AGAIN; |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
2910
diff
changeset
|
572 } |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
2910
diff
changeset
|
573 |
6022
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5980
diff
changeset
|
574 } else |
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5980
diff
changeset
|
575 #endif |
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5980
diff
changeset
|
576 #if (NGX_THREADS) |
6441
9fd738b85fad
Threads: task pointer stored in ngx_file_t.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6423
diff
changeset
|
577 if (ctx->thread_handler) { |
9fd738b85fad
Threads: task pointer stored in ngx_file_t.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6423
diff
changeset
|
578 src->file->thread_task = ctx->thread_task; |
9fd738b85fad
Threads: task pointer stored in ngx_file_t.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6423
diff
changeset
|
579 src->file->thread_handler = ctx->thread_handler; |
9fd738b85fad
Threads: task pointer stored in ngx_file_t.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6423
diff
changeset
|
580 src->file->thread_ctx = ctx->filter_ctx; |
9fd738b85fad
Threads: task pointer stored in ngx_file_t.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6423
diff
changeset
|
581 |
9fd738b85fad
Threads: task pointer stored in ngx_file_t.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6423
diff
changeset
|
582 n = ngx_thread_read(src->file, dst->pos, (size_t) size, |
9fd738b85fad
Threads: task pointer stored in ngx_file_t.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6423
diff
changeset
|
583 src->file_pos, ctx->pool); |
6022
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5980
diff
changeset
|
584 if (n == NGX_AGAIN) { |
6441
9fd738b85fad
Threads: task pointer stored in ngx_file_t.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6423
diff
changeset
|
585 ctx->thread_task = src->file->thread_task; |
6022
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5980
diff
changeset
|
586 return NGX_AGAIN; |
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5980
diff
changeset
|
587 } |
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5980
diff
changeset
|
588 |
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5980
diff
changeset
|
589 } else |
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5980
diff
changeset
|
590 #endif |
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
5980
diff
changeset
|
591 { |
3052
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
2910
diff
changeset
|
592 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
|
593 src->file_pos); |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
2910
diff
changeset
|
594 } |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
2910
diff
changeset
|
595 |
2248
1adec90a0e46
disable directio for unaligned reads in Linux
Igor Sysoev <igor@sysoev.ru>
parents:
2245
diff
changeset
|
596 #if (NGX_HAVE_ALIGNED_DIRECTIO) |
1adec90a0e46
disable directio for unaligned reads in Linux
Igor Sysoev <igor@sysoev.ru>
parents:
2245
diff
changeset
|
597 |
1adec90a0e46
disable directio for unaligned reads in Linux
Igor Sysoev <igor@sysoev.ru>
parents:
2245
diff
changeset
|
598 if (ctx->unaligned) { |
1adec90a0e46
disable directio for unaligned reads in Linux
Igor Sysoev <igor@sysoev.ru>
parents:
2245
diff
changeset
|
599 ngx_err_t err; |
1adec90a0e46
disable directio for unaligned reads in Linux
Igor Sysoev <igor@sysoev.ru>
parents:
2245
diff
changeset
|
600 |
1adec90a0e46
disable directio for unaligned reads in Linux
Igor Sysoev <igor@sysoev.ru>
parents:
2245
diff
changeset
|
601 err = ngx_errno; |
1adec90a0e46
disable directio for unaligned reads in Linux
Igor Sysoev <igor@sysoev.ru>
parents:
2245
diff
changeset
|
602 |
3164
b1b1775698d5
uniform ngx_directio_on/off() interface with other file functions
Igor Sysoev <igor@sysoev.ru>
parents:
3147
diff
changeset
|
603 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
|
604 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
|
605 ngx_directio_on_n " \"%s\" failed", |
1adec90a0e46
disable directio for unaligned reads in Linux
Igor Sysoev <igor@sysoev.ru>
parents:
2245
diff
changeset
|
606 src->file->name.data); |
1adec90a0e46
disable directio for unaligned reads in Linux
Igor Sysoev <igor@sysoev.ru>
parents:
2245
diff
changeset
|
607 } |
1adec90a0e46
disable directio for unaligned reads in Linux
Igor Sysoev <igor@sysoev.ru>
parents:
2245
diff
changeset
|
608 |
1adec90a0e46
disable directio for unaligned reads in Linux
Igor Sysoev <igor@sysoev.ru>
parents:
2245
diff
changeset
|
609 ngx_set_errno(err); |
1adec90a0e46
disable directio for unaligned reads in Linux
Igor Sysoev <igor@sysoev.ru>
parents:
2245
diff
changeset
|
610 |
1adec90a0e46
disable directio for unaligned reads in Linux
Igor Sysoev <igor@sysoev.ru>
parents:
2245
diff
changeset
|
611 ctx->unaligned = 0; |
1adec90a0e46
disable directio for unaligned reads in Linux
Igor Sysoev <igor@sysoev.ru>
parents:
2245
diff
changeset
|
612 } |
1adec90a0e46
disable directio for unaligned reads in Linux
Igor Sysoev <igor@sysoev.ru>
parents:
2245
diff
changeset
|
613 |
1adec90a0e46
disable directio for unaligned reads in Linux
Igor Sysoev <igor@sysoev.ru>
parents:
2245
diff
changeset
|
614 #endif |
1adec90a0e46
disable directio for unaligned reads in Linux
Igor Sysoev <igor@sysoev.ru>
parents:
2245
diff
changeset
|
615 |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
616 if (n == NGX_ERROR) { |
517 | 617 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
|
618 } |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
619 |
473 | 620 if (n != size) { |
2231
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2230
diff
changeset
|
621 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
|
622 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
|
623 n, size, src->file->name.data); |
3147
cbb1add4a6fe
fail if file size was changed
Igor Sysoev <igor@sysoev.ru>
parents:
3119
diff
changeset
|
624 return NGX_ERROR; |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
625 } |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
626 |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
627 dst->last += n; |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
628 |
452 | 629 if (sendfile) { |
630 dst->in_file = 1; | |
631 dst->file = src->file; | |
632 dst->file_pos = src->file_pos; | |
455 | 633 dst->file_last = src->file_pos + n; |
452 | 634 |
635 } 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
|
636 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
|
637 } |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
638 |
455 | 639 src->file_pos += n; |
640 | |
1238 | 641 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
|
642 dst->flush = src->flush; |
3e40f3e4376c
inherit flush flag, this fixes https proxying
Igor Sysoev <igor@sysoev.ru>
parents:
1226
diff
changeset
|
643 dst->last_buf = src->last_buf; |
2899
61d5b945730a
fix XSLT filter in SSI subrequests
Igor Sysoev <igor@sysoev.ru>
parents:
2316
diff
changeset
|
644 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
|
645 } |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
646 } |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
647 |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
648 return NGX_OK; |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
649 } |
162
96993d4d5067
nginx-0.0.1-2003-10-28-00:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
160
diff
changeset
|
650 |
96993d4d5067
nginx-0.0.1-2003-10-28-00:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
160
diff
changeset
|
651 |
499 | 652 ngx_int_t |
653 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
|
654 { |
166
389d7ee9fa60
nginx-0.0.1-2003-10-30-11:51:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
164
diff
changeset
|
655 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
|
656 |
1962 | 657 off_t size; |
6046
66176dfea01e
Output chain: free chain links in ngx_chain_writer().
Maxim Dounin <mdounin@mdounin.ru>
parents:
6045
diff
changeset
|
658 ngx_chain_t *cl, *ln, *chain; |
1962 | 659 ngx_connection_t *c; |
660 | |
661 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
|
662 |
473 | 663 for (size = 0; in; in = in->next) { |
664 | |
665 if (ngx_buf_size(in->buf) == 0 && !ngx_buf_special(in->buf)) { | |
6045
6ab301ddf469
Output chain: zero size buf alerts in ngx_chain_writer().
Maxim Dounin <mdounin@mdounin.ru>
parents:
6022
diff
changeset
|
666 |
6ab301ddf469
Output chain: zero size buf alerts in ngx_chain_writer().
Maxim Dounin <mdounin@mdounin.ru>
parents:
6022
diff
changeset
|
667 ngx_log_error(NGX_LOG_ALERT, ctx->pool->log, 0, |
6ab301ddf469
Output chain: zero size buf alerts in ngx_chain_writer().
Maxim Dounin <mdounin@mdounin.ru>
parents:
6022
diff
changeset
|
668 "zero size buf in chain writer " |
6ab301ddf469
Output chain: zero size buf alerts in ngx_chain_writer().
Maxim Dounin <mdounin@mdounin.ru>
parents:
6022
diff
changeset
|
669 "t:%d r:%d f:%d %p %p-%p %p %O-%O", |
6ab301ddf469
Output chain: zero size buf alerts in ngx_chain_writer().
Maxim Dounin <mdounin@mdounin.ru>
parents:
6022
diff
changeset
|
670 in->buf->temporary, |
6ab301ddf469
Output chain: zero size buf alerts in ngx_chain_writer().
Maxim Dounin <mdounin@mdounin.ru>
parents:
6022
diff
changeset
|
671 in->buf->recycled, |
6ab301ddf469
Output chain: zero size buf alerts in ngx_chain_writer().
Maxim Dounin <mdounin@mdounin.ru>
parents:
6022
diff
changeset
|
672 in->buf->in_file, |
6ab301ddf469
Output chain: zero size buf alerts in ngx_chain_writer().
Maxim Dounin <mdounin@mdounin.ru>
parents:
6022
diff
changeset
|
673 in->buf->start, |
6ab301ddf469
Output chain: zero size buf alerts in ngx_chain_writer().
Maxim Dounin <mdounin@mdounin.ru>
parents:
6022
diff
changeset
|
674 in->buf->pos, |
6ab301ddf469
Output chain: zero size buf alerts in ngx_chain_writer().
Maxim Dounin <mdounin@mdounin.ru>
parents:
6022
diff
changeset
|
675 in->buf->last, |
6ab301ddf469
Output chain: zero size buf alerts in ngx_chain_writer().
Maxim Dounin <mdounin@mdounin.ru>
parents:
6022
diff
changeset
|
676 in->buf->file, |
6ab301ddf469
Output chain: zero size buf alerts in ngx_chain_writer().
Maxim Dounin <mdounin@mdounin.ru>
parents:
6022
diff
changeset
|
677 in->buf->file_pos, |
6ab301ddf469
Output chain: zero size buf alerts in ngx_chain_writer().
Maxim Dounin <mdounin@mdounin.ru>
parents:
6022
diff
changeset
|
678 in->buf->file_last); |
6ab301ddf469
Output chain: zero size buf alerts in ngx_chain_writer().
Maxim Dounin <mdounin@mdounin.ru>
parents:
6022
diff
changeset
|
679 |
473 | 680 ngx_debug_point(); |
6045
6ab301ddf469
Output chain: zero size buf alerts in ngx_chain_writer().
Maxim Dounin <mdounin@mdounin.ru>
parents:
6022
diff
changeset
|
681 |
6ab301ddf469
Output chain: zero size buf alerts in ngx_chain_writer().
Maxim Dounin <mdounin@mdounin.ru>
parents:
6022
diff
changeset
|
682 continue; |
473 | 683 } |
7401
a7ff19afbb14
Negative size buffers detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6819
diff
changeset
|
684 |
a7ff19afbb14
Negative size buffers detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6819
diff
changeset
|
685 if (ngx_buf_size(in->buf) < 0) { |
a7ff19afbb14
Negative size buffers detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6819
diff
changeset
|
686 |
a7ff19afbb14
Negative size buffers detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6819
diff
changeset
|
687 ngx_log_error(NGX_LOG_ALERT, ctx->pool->log, 0, |
a7ff19afbb14
Negative size buffers detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6819
diff
changeset
|
688 "negative size buf in chain writer " |
a7ff19afbb14
Negative size buffers detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6819
diff
changeset
|
689 "t:%d r:%d f:%d %p %p-%p %p %O-%O", |
a7ff19afbb14
Negative size buffers detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6819
diff
changeset
|
690 in->buf->temporary, |
a7ff19afbb14
Negative size buffers detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6819
diff
changeset
|
691 in->buf->recycled, |
a7ff19afbb14
Negative size buffers detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6819
diff
changeset
|
692 in->buf->in_file, |
a7ff19afbb14
Negative size buffers detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6819
diff
changeset
|
693 in->buf->start, |
a7ff19afbb14
Negative size buffers detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6819
diff
changeset
|
694 in->buf->pos, |
a7ff19afbb14
Negative size buffers detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6819
diff
changeset
|
695 in->buf->last, |
a7ff19afbb14
Negative size buffers detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6819
diff
changeset
|
696 in->buf->file, |
a7ff19afbb14
Negative size buffers detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6819
diff
changeset
|
697 in->buf->file_pos, |
a7ff19afbb14
Negative size buffers detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6819
diff
changeset
|
698 in->buf->file_last); |
a7ff19afbb14
Negative size buffers detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6819
diff
changeset
|
699 |
a7ff19afbb14
Negative size buffers detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6819
diff
changeset
|
700 ngx_debug_point(); |
a7ff19afbb14
Negative size buffers detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6819
diff
changeset
|
701 |
a7ff19afbb14
Negative size buffers detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6819
diff
changeset
|
702 return NGX_ERROR; |
a7ff19afbb14
Negative size buffers detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6819
diff
changeset
|
703 } |
473 | 704 |
705 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
|
706 |
1962 | 707 ngx_log_debug2(NGX_LOG_DEBUG_CORE, c->log, 0, |
1226 | 708 "chain writer buf fl:%d s:%uO", |
709 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
|
710 |
501 | 711 cl = ngx_alloc_chain_link(ctx->pool); |
712 if (cl == NULL) { | |
461 | 713 return NGX_ERROR; |
714 } | |
501 | 715 |
461 | 716 cl->buf = in->buf; |
717 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
|
718 *ctx->last = cl; |
96993d4d5067
nginx-0.0.1-2003-10-28-00:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
160
diff
changeset
|
719 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
|
720 } |
96993d4d5067
nginx-0.0.1-2003-10-28-00:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
160
diff
changeset
|
721 |
1962 | 722 ngx_log_debug1(NGX_LOG_DEBUG_CORE, c->log, 0, |
461 | 723 "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
|
724 |
473 | 725 for (cl = ctx->out; cl; cl = cl->next) { |
726 | |
727 if (ngx_buf_size(cl->buf) == 0 && !ngx_buf_special(cl->buf)) { | |
6045
6ab301ddf469
Output chain: zero size buf alerts in ngx_chain_writer().
Maxim Dounin <mdounin@mdounin.ru>
parents:
6022
diff
changeset
|
728 |
6ab301ddf469
Output chain: zero size buf alerts in ngx_chain_writer().
Maxim Dounin <mdounin@mdounin.ru>
parents:
6022
diff
changeset
|
729 ngx_log_error(NGX_LOG_ALERT, ctx->pool->log, 0, |
6ab301ddf469
Output chain: zero size buf alerts in ngx_chain_writer().
Maxim Dounin <mdounin@mdounin.ru>
parents:
6022
diff
changeset
|
730 "zero size buf in chain writer " |
6ab301ddf469
Output chain: zero size buf alerts in ngx_chain_writer().
Maxim Dounin <mdounin@mdounin.ru>
parents:
6022
diff
changeset
|
731 "t:%d r:%d f:%d %p %p-%p %p %O-%O", |
6ab301ddf469
Output chain: zero size buf alerts in ngx_chain_writer().
Maxim Dounin <mdounin@mdounin.ru>
parents:
6022
diff
changeset
|
732 cl->buf->temporary, |
6ab301ddf469
Output chain: zero size buf alerts in ngx_chain_writer().
Maxim Dounin <mdounin@mdounin.ru>
parents:
6022
diff
changeset
|
733 cl->buf->recycled, |
6ab301ddf469
Output chain: zero size buf alerts in ngx_chain_writer().
Maxim Dounin <mdounin@mdounin.ru>
parents:
6022
diff
changeset
|
734 cl->buf->in_file, |
6ab301ddf469
Output chain: zero size buf alerts in ngx_chain_writer().
Maxim Dounin <mdounin@mdounin.ru>
parents:
6022
diff
changeset
|
735 cl->buf->start, |
6ab301ddf469
Output chain: zero size buf alerts in ngx_chain_writer().
Maxim Dounin <mdounin@mdounin.ru>
parents:
6022
diff
changeset
|
736 cl->buf->pos, |
6ab301ddf469
Output chain: zero size buf alerts in ngx_chain_writer().
Maxim Dounin <mdounin@mdounin.ru>
parents:
6022
diff
changeset
|
737 cl->buf->last, |
6ab301ddf469
Output chain: zero size buf alerts in ngx_chain_writer().
Maxim Dounin <mdounin@mdounin.ru>
parents:
6022
diff
changeset
|
738 cl->buf->file, |
6ab301ddf469
Output chain: zero size buf alerts in ngx_chain_writer().
Maxim Dounin <mdounin@mdounin.ru>
parents:
6022
diff
changeset
|
739 cl->buf->file_pos, |
6ab301ddf469
Output chain: zero size buf alerts in ngx_chain_writer().
Maxim Dounin <mdounin@mdounin.ru>
parents:
6022
diff
changeset
|
740 cl->buf->file_last); |
6ab301ddf469
Output chain: zero size buf alerts in ngx_chain_writer().
Maxim Dounin <mdounin@mdounin.ru>
parents:
6022
diff
changeset
|
741 |
473 | 742 ngx_debug_point(); |
6045
6ab301ddf469
Output chain: zero size buf alerts in ngx_chain_writer().
Maxim Dounin <mdounin@mdounin.ru>
parents:
6022
diff
changeset
|
743 |
6ab301ddf469
Output chain: zero size buf alerts in ngx_chain_writer().
Maxim Dounin <mdounin@mdounin.ru>
parents:
6022
diff
changeset
|
744 continue; |
473 | 745 } |
7401
a7ff19afbb14
Negative size buffers detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6819
diff
changeset
|
746 |
a7ff19afbb14
Negative size buffers detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6819
diff
changeset
|
747 if (ngx_buf_size(cl->buf) < 0) { |
a7ff19afbb14
Negative size buffers detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6819
diff
changeset
|
748 |
a7ff19afbb14
Negative size buffers detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6819
diff
changeset
|
749 ngx_log_error(NGX_LOG_ALERT, ctx->pool->log, 0, |
a7ff19afbb14
Negative size buffers detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6819
diff
changeset
|
750 "negative size buf in chain writer " |
a7ff19afbb14
Negative size buffers detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6819
diff
changeset
|
751 "t:%d r:%d f:%d %p %p-%p %p %O-%O", |
a7ff19afbb14
Negative size buffers detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6819
diff
changeset
|
752 cl->buf->temporary, |
a7ff19afbb14
Negative size buffers detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6819
diff
changeset
|
753 cl->buf->recycled, |
a7ff19afbb14
Negative size buffers detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6819
diff
changeset
|
754 cl->buf->in_file, |
a7ff19afbb14
Negative size buffers detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6819
diff
changeset
|
755 cl->buf->start, |
a7ff19afbb14
Negative size buffers detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6819
diff
changeset
|
756 cl->buf->pos, |
a7ff19afbb14
Negative size buffers detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6819
diff
changeset
|
757 cl->buf->last, |
a7ff19afbb14
Negative size buffers detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6819
diff
changeset
|
758 cl->buf->file, |
a7ff19afbb14
Negative size buffers detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6819
diff
changeset
|
759 cl->buf->file_pos, |
a7ff19afbb14
Negative size buffers detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6819
diff
changeset
|
760 cl->buf->file_last); |
a7ff19afbb14
Negative size buffers detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6819
diff
changeset
|
761 |
a7ff19afbb14
Negative size buffers detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6819
diff
changeset
|
762 ngx_debug_point(); |
a7ff19afbb14
Negative size buffers detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6819
diff
changeset
|
763 |
a7ff19afbb14
Negative size buffers detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6819
diff
changeset
|
764 return NGX_ERROR; |
a7ff19afbb14
Negative size buffers detection.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6819
diff
changeset
|
765 } |
473 | 766 |
767 size += ngx_buf_size(cl->buf); | |
768 } | |
769 | |
1962 | 770 if (size == 0 && !c->buffered) { |
473 | 771 return NGX_OK; |
772 } | |
773 | |
6046
66176dfea01e
Output chain: free chain links in ngx_chain_writer().
Maxim Dounin <mdounin@mdounin.ru>
parents:
6045
diff
changeset
|
774 chain = 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
|
775 |
1962 | 776 ngx_log_debug1(NGX_LOG_DEBUG_CORE, c->log, 0, |
6046
66176dfea01e
Output chain: free chain links in ngx_chain_writer().
Maxim Dounin <mdounin@mdounin.ru>
parents:
6045
diff
changeset
|
777 "chain writer out: %p", chain); |
291
117ccc7c4055
nginx-0.0.3-2004-03-16-16:35:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
778 |
6046
66176dfea01e
Output chain: free chain links in ngx_chain_writer().
Maxim Dounin <mdounin@mdounin.ru>
parents:
6045
diff
changeset
|
779 if (chain == NGX_CHAIN_ERROR) { |
162
96993d4d5067
nginx-0.0.1-2003-10-28-00:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
160
diff
changeset
|
780 return NGX_ERROR; |
96993d4d5067
nginx-0.0.1-2003-10-28-00:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
160
diff
changeset
|
781 } |
96993d4d5067
nginx-0.0.1-2003-10-28-00:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
160
diff
changeset
|
782 |
8673
862f6130d357
Upstream: sendfile_max_chunk support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7401
diff
changeset
|
783 if (chain && c->write->ready) { |
862f6130d357
Upstream: sendfile_max_chunk support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7401
diff
changeset
|
784 ngx_post_event(c->write, &ngx_posted_next_events); |
862f6130d357
Upstream: sendfile_max_chunk support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7401
diff
changeset
|
785 } |
862f6130d357
Upstream: sendfile_max_chunk support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7401
diff
changeset
|
786 |
6046
66176dfea01e
Output chain: free chain links in ngx_chain_writer().
Maxim Dounin <mdounin@mdounin.ru>
parents:
6045
diff
changeset
|
787 for (cl = ctx->out; cl && cl != chain; /* void */) { |
66176dfea01e
Output chain: free chain links in ngx_chain_writer().
Maxim Dounin <mdounin@mdounin.ru>
parents:
6045
diff
changeset
|
788 ln = cl; |
66176dfea01e
Output chain: free chain links in ngx_chain_writer().
Maxim Dounin <mdounin@mdounin.ru>
parents:
6045
diff
changeset
|
789 cl = cl->next; |
66176dfea01e
Output chain: free chain links in ngx_chain_writer().
Maxim Dounin <mdounin@mdounin.ru>
parents:
6045
diff
changeset
|
790 ngx_free_chain(ctx->pool, ln); |
66176dfea01e
Output chain: free chain links in ngx_chain_writer().
Maxim Dounin <mdounin@mdounin.ru>
parents:
6045
diff
changeset
|
791 } |
66176dfea01e
Output chain: free chain links in ngx_chain_writer().
Maxim Dounin <mdounin@mdounin.ru>
parents:
6045
diff
changeset
|
792 |
66176dfea01e
Output chain: free chain links in ngx_chain_writer().
Maxim Dounin <mdounin@mdounin.ru>
parents:
6045
diff
changeset
|
793 ctx->out = chain; |
66176dfea01e
Output chain: free chain links in ngx_chain_writer().
Maxim Dounin <mdounin@mdounin.ru>
parents:
6045
diff
changeset
|
794 |
162
96993d4d5067
nginx-0.0.1-2003-10-28-00:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
160
diff
changeset
|
795 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
|
796 ctx->last = &ctx->out; |
1211 | 797 |
1962 | 798 if (!c->buffered) { |
1215
fb3ff245c96b
an request body might not be passed to backend,
Igor Sysoev <igor@sysoev.ru>
parents:
1211
diff
changeset
|
799 return NGX_OK; |
fb3ff245c96b
an request body might not be passed to backend,
Igor Sysoev <igor@sysoev.ru>
parents:
1211
diff
changeset
|
800 } |
162
96993d4d5067
nginx-0.0.1-2003-10-28-00:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
160
diff
changeset
|
801 } |
96993d4d5067
nginx-0.0.1-2003-10-28-00:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
160
diff
changeset
|
802 |
96993d4d5067
nginx-0.0.1-2003-10-28-00:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
160
diff
changeset
|
803 return NGX_AGAIN; |
96993d4d5067
nginx-0.0.1-2003-10-28-00:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
160
diff
changeset
|
804 } |