Mercurial > hg > nginx
comparison src/event/ngx_event_pipe.c @ 257:70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Wed, 11 Feb 2004 17:08:49 +0000 |
parents | 2357fa41738a |
children | ec3c049681fd |
comparison
equal
deleted
inserted
replaced
256:8e39cab6abd5 | 257:70e1c7d2b83d |
---|---|
81 | 81 |
82 if (p->upstream_eof || p->upstream_error || p->upstream_done) { | 82 if (p->upstream_eof || p->upstream_error || p->upstream_done) { |
83 return NGX_OK; | 83 return NGX_OK; |
84 } | 84 } |
85 | 85 |
86 ngx_log_debug(p->log, "read upstream: %d" _ p->upstream->read->ready); | 86 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, p->log, 0, |
87 "pipe read upstream: %d", p->upstream->read->ready); | |
87 | 88 |
88 for ( ;; ) { | 89 for ( ;; ) { |
89 | 90 |
90 if (p->upstream_eof || p->upstream_error || p->upstream_done) { | 91 if (p->upstream_eof || p->upstream_error || p->upstream_done) { |
91 break; | 92 break; |
102 p->read = 1; | 103 p->read = 1; |
103 chain = p->preread_hunks; | 104 chain = p->preread_hunks; |
104 p->preread_hunks = NULL; | 105 p->preread_hunks = NULL; |
105 n = p->preread_size; | 106 n = p->preread_size; |
106 | 107 |
107 ngx_log_debug(p->log, "preread: %d" _ n); | 108 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, p->log, 0, |
109 "pipe preread: %d", n); | |
108 | 110 |
109 } else { | 111 } else { |
110 | 112 |
111 /* | 113 /* |
112 * kqueue notifies about the end of file or a pending error. | 114 * kqueue notifies about the end of file or a pending error. |
167 * a downstream is ready then write the hunks to a downstream | 169 * a downstream is ready then write the hunks to a downstream |
168 */ | 170 */ |
169 | 171 |
170 p->upstream_blocked = 1; | 172 p->upstream_blocked = 1; |
171 | 173 |
172 ngx_log_debug(p->log, "downstream ready"); | 174 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, p->log, 0, |
175 "pipe downstream ready"); | |
173 | 176 |
174 break; | 177 break; |
175 | 178 |
176 } else if (p->cachable | 179 } else if (p->cachable |
177 || p->temp_file->offset < p->max_temp_file_size) | 180 || p->temp_file->offset < p->max_temp_file_size) |
182 * to a temporary file, and add them to a r->out chain | 185 * to a temporary file, and add them to a r->out chain |
183 */ | 186 */ |
184 | 187 |
185 rc = ngx_event_pipe_write_chain_to_temp_file(p); | 188 rc = ngx_event_pipe_write_chain_to_temp_file(p); |
186 | 189 |
187 ngx_log_debug(p->log, "temp offset: %d" _ p->temp_file->offset); | 190 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, p->log, 0, |
191 "pipe temp offset: %d", p->temp_file->offset); | |
188 | 192 |
189 if (rc == NGX_AGAIN) { | 193 if (rc == NGX_AGAIN) { |
190 if (ngx_event_flags & NGX_USE_LEVEL_EVENT | 194 if (ngx_event_flags & NGX_USE_LEVEL_EVENT |
191 && p->upstream->read->active | 195 && p->upstream->read->active |
192 && p->upstream->read->ready) | 196 && p->upstream->read->ready) |
213 | 217 |
214 } else { | 218 } else { |
215 | 219 |
216 /* if there're no hunks to read in then disable a level event */ | 220 /* if there're no hunks to read in then disable a level event */ |
217 | 221 |
218 ngx_log_debug(p->log, "no hunks to read in"); | 222 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, p->log, 0, |
223 "no pipe hunks to read in"); | |
219 | 224 |
220 break; | 225 break; |
221 } | 226 } |
222 | 227 |
223 n = ngx_recv_chain(p->upstream, chain); | 228 n = ngx_recv_chain(p->upstream, chain); |
224 | 229 |
225 ngx_log_debug(p->log, "recv_chain: %d" _ n); | 230 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, p->log, 0, |
231 "pipe recv chain: %d", n); | |
226 | 232 |
227 if (p->free_raw_hunks) { | 233 if (p->free_raw_hunks) { |
228 chain->next = p->free_raw_hunks; | 234 chain->next = p->free_raw_hunks; |
229 } | 235 } |
230 p->free_raw_hunks = chain; | 236 p->free_raw_hunks = chain; |
310 { | 316 { |
311 size_t bsize, to_write; | 317 size_t bsize, to_write; |
312 ngx_hunk_t *h; | 318 ngx_hunk_t *h; |
313 ngx_chain_t *out, **ll, *cl, *tl; | 319 ngx_chain_t *out, **ll, *cl, *tl; |
314 | 320 |
315 ngx_log_debug(p->log, "write downstream: %d" _ p->downstream->write->ready); | 321 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, p->log, 0, |
322 "pipe write downstream: %d", p->downstream->write->ready); | |
316 | 323 |
317 for ( ;; ) { | 324 for ( ;; ) { |
318 if (p->downstream_error) { | 325 if (p->downstream_error) { |
319 return ngx_event_pipe_drain_chains(p); | 326 return ngx_event_pipe_drain_chains(p); |
320 } | 327 } |
381 cl->next = NULL; | 388 cl->next = NULL; |
382 ngx_chain_add_link(out, ll, cl); | 389 ngx_chain_add_link(out, ll, cl); |
383 } | 390 } |
384 | 391 |
385 if (out == NULL) { | 392 if (out == NULL) { |
386 ngx_log_debug(p->log, "no hunks to write BUSY: %d" _ to_write); | 393 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, p->log, 0, |
394 "pipe busy hunk data: %d", to_write); | |
387 | 395 |
388 if (!(p->upstream_blocked && to_write)) { | 396 if (!(p->upstream_blocked && to_write)) { |
389 break; | 397 break; |
390 } | 398 } |
391 | 399 |
470 | 478 |
471 size = 0; | 479 size = 0; |
472 cl = out; | 480 cl = out; |
473 ll = NULL; | 481 ll = NULL; |
474 | 482 |
475 ngx_log_debug(p->log, "offset: %d" _ p->temp_file->offset); | 483 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, p->log, 0, |
484 "pipe offset: %d", p->temp_file->offset); | |
476 | 485 |
477 do { | 486 do { |
478 hsize = cl->hunk->last - cl->hunk->pos; | 487 hsize = cl->hunk->last - cl->hunk->pos; |
479 | 488 |
480 ngx_log_debug(p->log, "hunk size: %d" _ hsize); | 489 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, p->log, 0, |
490 "pipe hunk size: %d", hsize); | |
481 | 491 |
482 if ((size + hsize > p->temp_file_write_size) | 492 if ((size + hsize > p->temp_file_write_size) |
483 || (p->temp_file->offset + size + hsize > p->max_temp_file_size)) | 493 || (p->temp_file->offset + size + hsize > p->max_temp_file_size)) |
484 { | 494 { |
485 break; | 495 break; |
489 ll = &cl->next; | 499 ll = &cl->next; |
490 cl = cl->next; | 500 cl = cl->next; |
491 | 501 |
492 } while (cl); | 502 } while (cl); |
493 | 503 |
494 ngx_log_debug(p->log, "size: %d" _ size); | 504 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, p->log, 0, "size: %d", size); |
495 | 505 |
496 if (cl) { | 506 if (cl) { |
497 p->in = cl; | 507 p->in = cl; |
498 *ll = NULL; | 508 *ll = NULL; |
499 | 509 |
582 h->tag = p->tag; | 592 h->tag = p->tag; |
583 h->type |= NGX_HUNK_LAST_SHADOW|NGX_HUNK_RECYCLED; | 593 h->type |= NGX_HUNK_LAST_SHADOW|NGX_HUNK_RECYCLED; |
584 hunk->shadow = h; | 594 hunk->shadow = h; |
585 | 595 |
586 ngx_alloc_link_and_set_hunk(cl, h, p->pool, NGX_ERROR); | 596 ngx_alloc_link_and_set_hunk(cl, h, p->pool, NGX_ERROR); |
587 ngx_log_debug(p->log, "HUNK %d" _ h->num); | 597 |
598 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, p->log, 0, "hunk #%d", h->num); | |
599 | |
588 ngx_chain_add_link(p->in, p->last_in, cl); | 600 ngx_chain_add_link(p->in, p->last_in, cl); |
589 | 601 |
590 return NGX_OK; | 602 return NGX_OK; |
591 } | 603 } |
592 | 604 |