diff options
author | Igor Sysoev <igor@sysoev.ru> | 2009-04-01 15:51:04 +0000 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2009-04-01 15:51:04 +0000 |
commit | 2a9aa8fc491206fdad62e685a55db7d68ab3ebb4 (patch) | |
tree | 21014c7d1b51ebadae8c941c90d3efc42a739879 | |
parent | 8ec919d16f63aeed10e71a49b1dc2fbbdb244d73 (diff) | |
download | nginx-2a9aa8fc491206fdad62e685a55db7d68ab3ebb4.tar.gz |
r2361 merge:
read and process upstream header in cycle,
this fixes the case when local FastCGI server sends many warnings in stderr
-rw-r--r-- | src/http/ngx_http_upstream.c | 67 |
1 files changed, 32 insertions, 35 deletions
diff --git a/src/http/ngx_http_upstream.c b/src/http/ngx_http_upstream.c index bb235db8a..83b60f7f5 100644 --- a/src/http/ngx_http_upstream.c +++ b/src/http/ngx_http_upstream.c @@ -1099,62 +1099,59 @@ ngx_http_upstream_process_header(ngx_event_t *rev) #endif } - n = c->recv(c, u->buffer.last, u->buffer.end - u->buffer.last); + for ( ;; ) { + + n = c->recv(c, u->buffer.last, u->buffer.end - u->buffer.last); - if (n == NGX_AGAIN) { + if (n == NGX_AGAIN) { #if 0 - ngx_add_timer(rev, u->read_timeout); + ngx_add_timer(rev, u->read_timeout); #endif - if (ngx_handle_read_event(rev, 0) == NGX_ERROR) { - ngx_http_upstream_finalize_request(r, u, + if (ngx_handle_read_event(rev, 0) == NGX_ERROR) { + ngx_http_upstream_finalize_request(r, u, NGX_HTTP_INTERNAL_SERVER_ERROR); + return; + } + return; } - return; - } - - if (n == 0) { - ngx_log_error(NGX_LOG_ERR, rev->log, 0, - "upstream prematurely closed connection"); - } + if (n == 0) { + ngx_log_error(NGX_LOG_ERR, rev->log, 0, + "upstream prematurely closed connection"); + } - if (n == NGX_ERROR || n == 0) { - ngx_http_upstream_next(r, u, NGX_HTTP_UPSTREAM_FT_ERROR); - return; - } + if (n == NGX_ERROR || n == 0) { + ngx_http_upstream_next(r, u, NGX_HTTP_UPSTREAM_FT_ERROR); + return; + } - u->buffer.last += n; + u->buffer.last += n; #if 0 - u->valid_header_in = 0; + u->valid_header_in = 0; - u->peer.cached = 0; + u->peer.cached = 0; #endif - rc = u->process_header(r); + rc = u->process_header(r); - if (rc == NGX_AGAIN) { -#if 0 - ngx_add_timer(rev, u->read_timeout); -#endif + if (rc == NGX_AGAIN) { - if (u->buffer.pos == u->buffer.end) { - ngx_log_error(NGX_LOG_ERR, rev->log, 0, - "upstream sent too big header"); + if (u->buffer.pos == u->buffer.end) { + ngx_log_error(NGX_LOG_ERR, rev->log, 0, + "upstream sent too big header"); - ngx_http_upstream_next(r, u, NGX_HTTP_UPSTREAM_FT_INVALID_HEADER); - return; - } + ngx_http_upstream_next(r, u, + NGX_HTTP_UPSTREAM_FT_INVALID_HEADER); + return; + } - if (ngx_handle_read_event(rev, 0) == NGX_ERROR) { - ngx_http_upstream_finalize_request(r, u, - NGX_HTTP_INTERNAL_SERVER_ERROR); - return; + continue; } - return; + break; } if (rc == NGX_HTTP_UPSTREAM_INVALID_HEADER) { |