comparison src/http/ngx_http_output_filter.c @ 94:8220378432a8

nginx-0.0.1-2003-05-22-19:23:47 import
author Igor Sysoev <igor@sysoev.ru>
date Thu, 22 May 2003 15:23:47 +0000
parents 637625a2acdb
children b48066122884
comparison
equal deleted inserted replaced
93:738fe44c70d5 94:8220378432a8
56 }; 56 };
57 57
58 58
59 #define next_filter (*ngx_http_top_body_filter) 59 #define next_filter (*ngx_http_top_body_filter)
60 60
61 #if 0
62 static int (*next_filter) (ngx_http_request_t *r, ngx_chain_t *ch);
63 #endif
64
65
66 #if 0
67 #define next_filter ngx_http_output_filter_module_ctx.next_output_body_filter
68 #endif
69
70 #define need_to_copy(r, hunk) \ 61 #define need_to_copy(r, hunk) \
71 (((r->filter & NGX_HTTP_FILTER_NEED_IN_MEMORY) \ 62 (((r->filter & NGX_HTTP_FILTER_NEED_IN_MEMORY) \
72 && (hunk->type & NGX_HUNK_IN_MEMORY) == 0) \ 63 && (hunk->type & NGX_HUNK_IN_MEMORY) == 0) \
73 || ((r->filter & NGX_HTTP_FILTER_NEED_TEMP) \ 64 || ((r->filter & NGX_HTTP_FILTER_NEED_TEMP) \
74 && (hunk->type & (NGX_HUNK_MEMORY|NGX_HUNK_MMAP)))) 65 && (hunk->type & (NGX_HUNK_MEMORY|NGX_HUNK_MMAP))))
157 148
158 if (rc == NGX_ERROR || rc == NGX_AGAIN) { 149 if (rc == NGX_ERROR || rc == NGX_AGAIN) {
159 return rc; 150 return rc;
160 } 151 }
161 152
153 ngx_log_debug(r->connection->log, "HERE");
154
162 /* NGX_OK */ 155 /* NGX_OK */
163 /* set our hunk free */ 156 /* set our hunk free */
164 ctx->hunk->pos = ctx->hunk->last = ctx->hunk->start; 157 ctx->hunk->pos = ctx->hunk->last = ctx->hunk->start;
165 } 158 }
166 159
209 #if (NGX_FILE_AIO_READ) 202 #if (NGX_FILE_AIO_READ)
210 if (rc == NGX_AGAIN) { 203 if (rc == NGX_AGAIN) {
211 return rc; 204 return rc;
212 } 205 }
213 #endif 206 #endif
207
208 if (ctx->incoming->hunk->type & NGX_HUNK_IN_MEMORY) {
209 size = ctx->incoming->hunk->last - ctx->incoming->hunk->pos;
210
211 } else {
212 size = ctx->incoming->hunk->file_last
213 - ctx->incoming->hunk->file_pos;
214 }
215
216 /* delete the completed hunk from the incoming chain */
217 if (size == 0) {
218 ctx->incoming = ctx->incoming->next;
219 }
220
214 ctx->out.hunk = ctx->hunk; 221 ctx->out.hunk = ctx->hunk;
215 ctx->out.next = NULL; 222 ctx->out.next = NULL;
216 223
217 rc = next_filter(r, &ctx->out); 224 rc = next_filter(r, &ctx->out);
218 if (rc == NGX_ERROR || rc == NGX_AGAIN) { 225 if (rc == NGX_ERROR || rc == NGX_AGAIN) {
224 ctx->hunk->pos = ctx->hunk->last = ctx->hunk->start; 231 ctx->hunk->pos = ctx->hunk->last = ctx->hunk->start;
225 232
226 /* repeat until we will have copied the whole first hunk from 233 /* repeat until we will have copied the whole first hunk from
227 the chain ctx->incoming */ 234 the chain ctx->incoming */
228 235
229 if (ctx->incoming->hunk->type & NGX_HUNK_IN_MEMORY) {
230 size = ctx->incoming->hunk->last - ctx->incoming->hunk->pos;
231
232 } else {
233 size = ctx->incoming->hunk->file_last
234 - ctx->incoming->hunk->file_pos;
235 }
236
237 } while (size); 236 } while (size);
238
239 /* delete the completed hunk from the incoming chain */
240 ctx->incoming = ctx->incoming->next;
241 237
242 /* repeat until we will have processed the whole chain ctx->incoming */ 238 /* repeat until we will have processed the whole chain ctx->incoming */
243 } while (ctx->incoming); 239 } while (ctx->incoming);
244 240
245 return NGX_OK; 241 return NGX_OK;
273 dst->type |= NGX_HUNK_LAST; 269 dst->type |= NGX_HUNK_LAST;
274 } 270 }
275 271
276 } else { 272 } else {
277 n = ngx_read_file(src->file, dst->pos, size, src->file_pos); 273 n = ngx_read_file(src->file, dst->pos, size, src->file_pos);
274
275 if (n == 0) {
276 ngx_log_debug(src->file->log, "READ: %qd:%qd %X:%X %X:%X" _
277 src->file_pos _ src->file_last _
278 dst->pos _ dst->last _ dst->start _ dst->end);
279 }
278 280
279 if (n == NGX_ERROR) { 281 if (n == NGX_ERROR) {
280 return n; 282 return n;
281 } 283 }
282 284