comparison src/event/ngx_event_pipe.c @ 3052:6060225e9261

FreeBSD and Linux AIO support
author Igor Sysoev <igor@sysoev.ru>
date Fri, 28 Aug 2009 08:12:35 +0000
parents f54b02dbb12b
children 227a819b46db e917fc5eceb7
comparison
equal deleted inserted replaced
3051:26dfc0fa22c8 3052:6060225e9261
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 }
608 flush: 617 flush:
609 618
610 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, p->log, 0, 619 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, p->log, 0,
611 "pipe write: out:%p, f:%d", out, flush); 620 "pipe write: out:%p, f:%d", out, flush);
612 621
613 if (out == NULL && !flush) { 622 if (out == NULL) {
614 break; 623
624 if (!flush) {
625 break;
626 }
627
628 /* a workaround for AIO */
629 if (flushed++ > 10) {
630 return NGX_BUSY;
631 }
615 } 632 }
616 633
617 rc = p->output_filter(p->output_ctx, out); 634 rc = p->output_filter(p->output_ctx, out);
618 635
619 if (rc == NGX_ERROR) { 636 if (rc == NGX_ERROR) {