comparison src/event/ngx_event_pipe.c @ 518:86dad910eeb6 NGINX_0_8_11

nginx 0.8.11 *) Change: directive "gzip_disable msie6" enables gzipping for MSIE 6.0 SV1. *) Feature: file AIO support on FreeBSD and Linux. *) Feature: the "directio_alignment" directive.
author Igor Sysoev <http://sysoev.ru>
date Fri, 28 Aug 2009 00:00:00 +0400
parents 6484cbba0222
children 943566b4d82e
comparison
equal deleted inserted replaced
517:15b5cddc5190 518:86dad910eeb6
22 22
23 ngx_int_t 23 ngx_int_t
24 ngx_event_pipe(ngx_event_pipe_t *p, ngx_int_t do_write) 24 ngx_event_pipe(ngx_event_pipe_t *p, ngx_int_t do_write)
25 { 25 {
26 u_int flags; 26 u_int flags;
27 ngx_int_t rc;
27 ngx_event_t *rev, *wev; 28 ngx_event_t *rev, *wev;
28 29
29 for ( ;; ) { 30 for ( ;; ) {
30 if (do_write) { 31 if (do_write) {
31 p->log->action = "sending to client"; 32 p->log->action = "sending to client";
32 33
33 if (ngx_event_pipe_write_to_downstream(p) == NGX_ABORT) { 34 rc = ngx_event_pipe_write_to_downstream(p);
35
36 if (rc == NGX_ABORT) {
34 return NGX_ABORT; 37 return NGX_ABORT;
38 }
39
40 if (rc == NGX_BUSY) {
41 return NGX_OK;
35 } 42 }
36 } 43 }
37 44
38 p->read = 0; 45 p->read = 0;
39 p->upstream_blocked = 0; 46 p->upstream_blocked = 0;
420 ngx_event_pipe_write_to_downstream(ngx_event_pipe_t *p) 427 ngx_event_pipe_write_to_downstream(ngx_event_pipe_t *p)
421 { 428 {
422 u_char *prev; 429 u_char *prev;
423 size_t bsize; 430 size_t bsize;
424 ngx_int_t rc; 431 ngx_int_t rc;
425 ngx_uint_t flush, prev_last_shadow; 432 ngx_uint_t flush, flushed, prev_last_shadow;
426 ngx_chain_t *out, **ll, *cl, file; 433 ngx_chain_t *out, **ll, *cl, file;
427 ngx_connection_t *downstream; 434 ngx_connection_t *downstream;
428 435
429 downstream = p->downstream; 436 downstream = p->downstream;
430 437
431 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, p->log, 0, 438 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, p->log, 0,
432 "pipe write downstream: %d", downstream->write->ready); 439 "pipe write downstream: %d", downstream->write->ready);
440
441 flushed = 0;
433 442
434 for ( ;; ) { 443 for ( ;; ) {
435 if (p->downstream_error) { 444 if (p->downstream_error) {
436 return ngx_event_pipe_drain_chains(p); 445 return ngx_event_pipe_drain_chains(p);
437 } 446 }
452 cl->buf->recycled = 0; 461 cl->buf->recycled = 0;
453 } 462 }
454 463
455 rc = p->output_filter(p->output_ctx, p->out); 464 rc = p->output_filter(p->output_ctx, p->out);
456 465
457 if (downstream->destroyed) {
458 return NGX_ABORT;
459 }
460
461 if (rc == NGX_ERROR) { 466 if (rc == NGX_ERROR) {
462 p->downstream_error = 1; 467 p->downstream_error = 1;
463 return ngx_event_pipe_drain_chains(p); 468 return ngx_event_pipe_drain_chains(p);
464 } 469 }
465 470
473 for (cl = p->in; cl; cl = cl->next) { 478 for (cl = p->in; cl; cl = cl->next) {
474 cl->buf->recycled = 0; 479 cl->buf->recycled = 0;
475 } 480 }
476 481
477 rc = p->output_filter(p->output_ctx, p->in); 482 rc = p->output_filter(p->output_ctx, p->in);
478
479 if (downstream->destroyed) {
480 return NGX_ABORT;
481 }
482 483
483 if (rc == NGX_ERROR) { 484 if (rc == NGX_ERROR) {
484 p->downstream_error = 1; 485 p->downstream_error = 1;
485 return ngx_event_pipe_drain_chains(p); 486 return ngx_event_pipe_drain_chains(p);
486 } 487 }
616 flush: 617 flush:
617 618
618 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, p->log, 0, 619 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, p->log, 0,
619 "pipe write: out:%p, f:%d", out, flush); 620 "pipe write: out:%p, f:%d", out, flush);
620 621
621 if (out == NULL && !flush) { 622 if (out == NULL) {
622 break; 623
624 if (!flush) {
625 break;
626 }
627
628 /* a workaround for AIO */
629 if (flushed++ > 10) {
630 return NGX_BUSY;
631 }
623 } 632 }
624 633
625 rc = p->output_filter(p->output_ctx, out); 634 rc = p->output_filter(p->output_ctx, out);
626
627 if (downstream->destroyed) {
628 return NGX_ABORT;
629 }
630 635
631 if (rc == NGX_ERROR) { 636 if (rc == NGX_ERROR) {
632 p->downstream_error = 1; 637 p->downstream_error = 1;
633 return ngx_event_pipe_drain_chains(p); 638 return ngx_event_pipe_drain_chains(p);
634 } 639 }