Mercurial > hg > nginx
comparison src/event/ngx_event_proxy.c @ 146:5ac79e574285
nginx-0.0.1-2003-10-14-09:26:00 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Tue, 14 Oct 2003 05:26:00 +0000 |
parents | 58557d0cccd1 |
children | be71fca7f9d7 |
comparison
equal
deleted
inserted
replaced
145:58557d0cccd1 | 146:5ac79e574285 |
---|---|
108 p->file_hunks = NULL; | 108 p->file_hunks = NULL; |
109 | 109 |
110 ngx_log_debug(p->log, "file hunk: %08X" _ chain->hunk _ | 110 ngx_log_debug(p->log, "file hunk: %08X" _ chain->hunk _ |
111 chain->hunk->end - chain->hunk->last); | 111 chain->hunk->end - chain->hunk->last); |
112 | 112 |
113 } else if (p->cachable == 0 && p->downstream->write->ready) { | 113 } else if (!p->cachable && p->downstream->write->ready) { |
114 | 114 |
115 /* | 115 /* |
116 * if the hunks are not needed to be saved in a cache and | 116 * if the hunks are not needed to be saved in a cache and |
117 * a downstream is ready then write the hunks to a downstream | 117 * a downstream is ready then write the hunks to a downstream |
118 */ | 118 */ |
392 } | 392 } |
393 | 393 |
394 | 394 |
395 int ngx_event_proxy_write_to_downstream(ngx_event_proxy_t *p) | 395 int ngx_event_proxy_write_to_downstream(ngx_event_proxy_t *p) |
396 { | 396 { |
397 ngx_chain_t *out, *ce; | |
398 ngx_event_proxy_downstream_t *d; | |
399 | |
400 d = &p->downstream; | |
401 | |
402 for ( ;; ) { | |
403 | |
404 if (!d->write->ready || p->busy_hunks_num == p->max_busy_hunks) { | |
405 break; | |
406 } | |
407 | |
408 if (p->out) { | |
409 out = p->out; | |
410 p->out = p->out->next; | |
411 | |
412 } else if (!p->cachable && p->in) { | |
413 out = p->in; | |
414 p->in = p->in->next; | |
415 | |
416 } else { | |
417 break; | |
418 } | |
419 | |
420 out->next = NULL; | |
421 | |
422 rc = p->output_filter(p->output_data, out->hunk); | |
423 | |
424 ngx_chain_update_chains(p->shadow_free, p->busy, out); | |
425 | |
426 for (ce = p->shadow_free; ce; ce = ce->next) { | |
427 | |
428 if (ce->hunk->type & NGX_LAST_SHADOW_HUNK) { | |
429 h = ce->hunk->shadow; | |
430 h->type = (NGX_HUNK_TEMP|NGX_HUNK_IN_MEMORY|NGX_HUNK_RECYCLED); | |
431 h->pos = p->last = h->start; | |
432 h->shadow = NULL; | |
433 | |
434 ngx_alloc_ce_and_set_hunk(te, h, p->pool, NGX_ABORT); | |
435 te->next = p->free; | |
436 p->free = te; | |
437 } | |
438 } | |
439 | |
440 p->busy_hunks_num = 0; | |
441 for (ce = p->busy; ce; ce = ce->next) { | |
442 if (ce->hunk->type & NGX_LAST_SHADOW_HUNK) { | |
443 p->busy_hunks_num++; | |
444 } | |
445 } | |
446 | |
447 if (p->upstream.read->ready) | |
448 if (ngx_event_proxy_read_upstream(p) == NGX_ERROR) { | |
449 return NGX_ABORT; | |
450 } | |
451 } | |
452 } | |
453 | |
454 if (d->level == 0) { | |
455 if (ngx_handler_write_event(d->write) == NGX_ERROR) { | |
456 return NGX_ABORT; | |
457 } | |
458 } | |
459 | |
460 if (p->upstream_done && p->in == NULL && p->out == NULL) { | |
461 p->downstream_done = 1; | |
462 } | |
463 | |
464 return NGX_OK; | |
465 } | |
466 | |
467 | |
468 | |
469 int ngx_event_proxy_write_to_downstream(ngx_event_proxy_t *p) | |
470 { | |
397 int rc; | 471 int rc; |
398 ngx_hunk_t *h; | 472 ngx_hunk_t *h; |
399 ngx_chain_t *entry; | 473 ngx_chain_t *entry; |
400 | 474 |
401 #if 0 | 475 #if 0 |
684 ngx_hunk_t *h; | 758 ngx_hunk_t *h; |
685 ngx_chain_t *ce, *temp; | 759 ngx_chain_t *ce, *temp; |
686 | 760 |
687 if (p->upstream_eof) { | 761 if (p->upstream_eof) { |
688 | 762 |
689 /* THINK comment */ | 763 /* TODO: comment */ |
690 | 764 |
691 ce = p->free_hunks; | 765 ce = p->free_hunks; |
692 | 766 |
693 ngx_chain_add_ce(p->in_hunk, p->last_in_hunk, ce); | 767 ngx_chain_add_ce(p->in_hunk, p->last_in_hunk, ce); |
694 | 768 |