Klaus Demo nginx / d23dc7d
Upstream: ngx_http_upstream_finalize_request(NGX_ERROR) on errors. Previously, ngx_http_upstream_finalize_request(0) was used in most cases after errors. While with current code there is no difference, use of NGX_ERROR allows to pass a bit more information into ngx_http_upstream_finalize_request(). Maxim Dounin 9 years ago
1 changed file(s) with 25 addition(s) and 25 deletion(s). Raw diff Collapse all Expand all
21432143 r->limit_rate = 0;
21442144
21452145 if (u->input_filter_init(u->input_filter_ctx) == NGX_ERROR) {
2146 ngx_http_upstream_finalize_request(r, u, 0);
2146 ngx_http_upstream_finalize_request(r, u, NGX_ERROR);
21472147 return;
21482148 }
21492149
21572157 {
21582158 ngx_connection_error(c, ngx_socket_errno,
21592159 "setsockopt(TCP_NODELAY) failed");
2160 ngx_http_upstream_finalize_request(r, u, 0);
2160 ngx_http_upstream_finalize_request(r, u, NGX_ERROR);
21612161 return;
21622162 }
21632163
21722172 u->state->response_length += n;
21732173
21742174 if (u->input_filter(u->input_filter_ctx, n) == NGX_ERROR) {
2175 ngx_http_upstream_finalize_request(r, u, 0);
2175 ngx_http_upstream_finalize_request(r, u, NGX_ERROR);
21762176 return;
21772177 }
21782178
21832183 u->buffer.last = u->buffer.start;
21842184
21852185 if (ngx_http_send_special(r, NGX_HTTP_FLUSH) == NGX_ERROR) {
2186 ngx_http_upstream_finalize_request(r, u, 0);
2186 ngx_http_upstream_finalize_request(r, u, NGX_ERROR);
21872187 return;
21882188 }
21892189
22072207 switch (ngx_http_test_predicates(r, u->conf->no_cache)) {
22082208
22092209 case NGX_ERROR:
2210 ngx_http_upstream_finalize_request(r, u, 0);
2210 ngx_http_upstream_finalize_request(r, u, NGX_ERROR);
22112211 return;
22122212
22132213 case NGX_DECLINED:
22232223 r->cache->file_cache = u->conf->cache->data;
22242224
22252225 if (ngx_http_file_cache_create(r) != NGX_OK) {
2226 ngx_http_upstream_finalize_request(r, u, 0);
2226 ngx_http_upstream_finalize_request(r, u, NGX_ERROR);
22272227 return;
22282228 }
22292229 }
22842284
22852285 p->temp_file = ngx_pcalloc(r->pool, sizeof(ngx_temp_file_t));
22862286 if (p->temp_file == NULL) {
2287 ngx_http_upstream_finalize_request(r, u, 0);
2287 ngx_http_upstream_finalize_request(r, u, NGX_ERROR);
22882288 return;
22892289 }
22902290
23072307
23082308 p->preread_bufs = ngx_alloc_chain_link(r->pool);
23092309 if (p->preread_bufs == NULL) {
2310 ngx_http_upstream_finalize_request(r, u, 0);
2310 ngx_http_upstream_finalize_request(r, u, NGX_ERROR);
23112311 return;
23122312 }
23132313
23212321
23222322 p->buf_to_file = ngx_calloc_buf(r->pool);
23232323 if (p->buf_to_file == NULL) {
2324 ngx_http_upstream_finalize_request(r, u, 0);
2324 ngx_http_upstream_finalize_request(r, u, NGX_ERROR);
23252325 return;
23262326 }
23272327
23692369 if (u->input_filter_init
23702370 && u->input_filter_init(p->input_ctx) != NGX_OK)
23712371 {
2372 ngx_http_upstream_finalize_request(r, u, 0);
2372 ngx_http_upstream_finalize_request(r, u, NGX_ERROR);
23732373 return;
23742374 }
23752375
24112411 {
24122412 ngx_connection_error(c, ngx_socket_errno,
24132413 "setsockopt(TCP_NODELAY) failed");
2414 ngx_http_upstream_finalize_request(r, u, 0);
2414 ngx_http_upstream_finalize_request(r, u, NGX_ERROR);
24152415 return;
24162416 }
24172417
24272427 {
24282428 ngx_connection_error(u->peer.connection, ngx_socket_errno,
24292429 "setsockopt(TCP_NODELAY) failed");
2430 ngx_http_upstream_finalize_request(r, u, 0);
2430 ngx_http_upstream_finalize_request(r, u, NGX_ERROR);
24312431 return;
24322432 }
24332433
24362436 }
24372437
24382438 if (ngx_http_send_special(r, NGX_HTTP_FLUSH) == NGX_ERROR) {
2439 ngx_http_upstream_finalize_request(r, u, 0);
2439 ngx_http_upstream_finalize_request(r, u, NGX_ERROR);
24402440 return;
24412441 }
24422442
25362536 if (b->start == NULL) {
25372537 b->start = ngx_palloc(r->pool, u->conf->buffer_size);
25382538 if (b->start == NULL) {
2539 ngx_http_upstream_finalize_request(r, u, 0);
2539 ngx_http_upstream_finalize_request(r, u, NGX_ERROR);
25402540 return;
25412541 }
25422542
25592559 n = dst->send(dst, b->pos, size);
25602560
25612561 if (n == NGX_ERROR) {
2562 ngx_http_upstream_finalize_request(r, u, 0);
2562 ngx_http_upstream_finalize_request(r, u, NGX_ERROR);
25632563 return;
25642564 }
25652565
26142614 if (ngx_handle_write_event(upstream->write, u->conf->send_lowat)
26152615 != NGX_OK)
26162616 {
2617 ngx_http_upstream_finalize_request(r, u, 0);
2617 ngx_http_upstream_finalize_request(r, u, NGX_ERROR);
26182618 return;
26192619 }
26202620
26262626 }
26272627
26282628 if (ngx_handle_read_event(upstream->read, 0) != NGX_OK) {
2629 ngx_http_upstream_finalize_request(r, u, 0);
2629 ngx_http_upstream_finalize_request(r, u, NGX_ERROR);
26302630 return;
26312631 }
26322632
26402640 if (ngx_handle_write_event(downstream->write, clcf->send_lowat)
26412641 != NGX_OK)
26422642 {
2643 ngx_http_upstream_finalize_request(r, u, 0);
2643 ngx_http_upstream_finalize_request(r, u, NGX_ERROR);
26442644 return;
26452645 }
26462646
26472647 if (ngx_handle_read_event(downstream->read, 0) != NGX_OK) {
2648 ngx_http_upstream_finalize_request(r, u, 0);
2648 ngx_http_upstream_finalize_request(r, u, NGX_ERROR);
26492649 return;
26502650 }
26512651
27362736 rc = ngx_http_output_filter(r, u->out_bufs);
27372737
27382738 if (rc == NGX_ERROR) {
2739 ngx_http_upstream_finalize_request(r, u, 0);
2739 ngx_http_upstream_finalize_request(r, u, NGX_ERROR);
27402740 return;
27412741 }
27422742
27732773 u->state->response_length += n;
27742774
27752775 if (u->input_filter(u->input_filter_ctx, n) == NGX_ERROR) {
2776 ngx_http_upstream_finalize_request(r, u, 0);
2776 ngx_http_upstream_finalize_request(r, u, NGX_ERROR);
27772777 return;
27782778 }
27792779 }
27922792 if (ngx_handle_write_event(downstream->write, clcf->send_lowat)
27932793 != NGX_OK)
27942794 {
2795 ngx_http_upstream_finalize_request(r, u, 0);
2795 ngx_http_upstream_finalize_request(r, u, NGX_ERROR);
27962796 return;
27972797 }
27982798 }
28052805 }
28062806
28072807 if (ngx_handle_read_event(upstream->read, 0) != NGX_OK) {
2808 ngx_http_upstream_finalize_request(r, u, 0);
2808 ngx_http_upstream_finalize_request(r, u, NGX_ERROR);
28092809 return;
28102810 }
28112811
28962896 ngx_add_timer(wev, p->send_timeout);
28972897
28982898 if (ngx_handle_write_event(wev, p->send_lowat) != NGX_OK) {
2899 ngx_http_upstream_finalize_request(r, u, 0);
2899 ngx_http_upstream_finalize_request(r, u, NGX_ERROR);
29002900 }
29012901
29022902 return;
29212921 "http downstream delayed");
29222922
29232923 if (ngx_handle_write_event(wev, p->send_lowat) != NGX_OK) {
2924 ngx_http_upstream_finalize_request(r, u, 0);
2924 ngx_http_upstream_finalize_request(r, u, NGX_ERROR);
29252925 }
29262926
29272927 return;