r2361 merge:
read and process upstream header in cycle, this fixes the case when local FastCGI server sends many warnings in stderr
This commit is contained in:
parent
30fc974145
commit
90adc10d7e
|
@ -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 ( ;; ) {
|
||||
|
||||
if (n == NGX_AGAIN) {
|
||||
n = c->recv(c, u->buffer.last, u->buffer.end - u->buffer.last);
|
||||
|
||||
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 == NGX_ERROR || n == 0) {
|
||||
ngx_http_upstream_next(r, u, NGX_HTTP_UPSTREAM_FT_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
u->buffer.last += n;
|
||||
|
||||
#if 0
|
||||
u->valid_header_in = 0;
|
||||
|
||||
u->peer.cached = 0;
|
||||
#endif
|
||||
|
||||
rc = u->process_header(r);
|
||||
|
||||
if (rc == NGX_AGAIN) {
|
||||
#if 0
|
||||
ngx_add_timer(rev, u->read_timeout);
|
||||
#endif
|
||||
|
||||
if (u->buffer.pos == u->buffer.end) {
|
||||
if (n == 0) {
|
||||
ngx_log_error(NGX_LOG_ERR, rev->log, 0,
|
||||
"upstream sent too big header");
|
||||
"upstream prematurely closed connection");
|
||||
}
|
||||
|
||||
ngx_http_upstream_next(r, u, NGX_HTTP_UPSTREAM_FT_INVALID_HEADER);
|
||||
if (n == NGX_ERROR || n == 0) {
|
||||
ngx_http_upstream_next(r, u, NGX_HTTP_UPSTREAM_FT_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
if (ngx_handle_read_event(rev, 0) == NGX_ERROR) {
|
||||
ngx_http_upstream_finalize_request(r, u,
|
||||
NGX_HTTP_INTERNAL_SERVER_ERROR);
|
||||
return;
|
||||
u->buffer.last += n;
|
||||
|
||||
#if 0
|
||||
u->valid_header_in = 0;
|
||||
|
||||
u->peer.cached = 0;
|
||||
#endif
|
||||
|
||||
rc = u->process_header(r);
|
||||
|
||||
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");
|
||||
|
||||
ngx_http_upstream_next(r, u,
|
||||
NGX_HTTP_UPSTREAM_FT_INVALID_HEADER);
|
||||
return;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
return;
|
||||
break;
|
||||
}
|
||||
|
||||
if (rc == NGX_HTTP_UPSTREAM_INVALID_HEADER) {
|
||||
|
|
Loading…
Reference in New Issue