comparison src/http/ngx_http_upstream.c @ 5112:d3c15c7831eb

Upstream: call ngx_http_run_posted_requests() on resolve errors. If proxy_pass to a host with dynamic resolution was used to handle a subrequest, and host resolution failed, the main request wasn't run till something else happened on the connection. E.g. request to "/zzz" with the following configuration hanged: addition_types *; resolver 8.8.8.8; location /test { set $ihost xxx; proxy_pass http://$ihost; } location /zzz { add_after_body /test; return 200 "test"; } Report and original version of the patch by Lanshun Zhou, http://mailman.nginx.org/pipermail/nginx-devel/2013-March/003476.html.
author Maxim Dounin <mdounin@mdounin.ru>
date Thu, 14 Mar 2013 12:37:54 +0000
parents 93713d4b99c3
children 08b36f2afc3f
comparison
equal deleted inserted replaced
5111:57c3f84d72ce 5112:d3c15c7831eb
892 "%V could not be resolved (%i: %s)", 892 "%V could not be resolved (%i: %s)",
893 &ctx->name, ctx->state, 893 &ctx->name, ctx->state,
894 ngx_resolver_strerror(ctx->state)); 894 ngx_resolver_strerror(ctx->state));
895 895
896 ngx_http_upstream_finalize_request(r, u, NGX_HTTP_BAD_GATEWAY); 896 ngx_http_upstream_finalize_request(r, u, NGX_HTTP_BAD_GATEWAY);
897 return; 897 goto failed;
898 } 898 }
899 899
900 ur->naddrs = ctx->naddrs; 900 ur->naddrs = ctx->naddrs;
901 ur->addrs = ctx->addrs; 901 ur->addrs = ctx->addrs;
902 902
917 #endif 917 #endif
918 918
919 if (ngx_http_upstream_create_round_robin_peer(r, ur) != NGX_OK) { 919 if (ngx_http_upstream_create_round_robin_peer(r, ur) != NGX_OK) {
920 ngx_http_upstream_finalize_request(r, u, 920 ngx_http_upstream_finalize_request(r, u,
921 NGX_HTTP_INTERNAL_SERVER_ERROR); 921 NGX_HTTP_INTERNAL_SERVER_ERROR);
922 return; 922 goto failed;
923 } 923 }
924 924
925 ngx_resolve_name_done(ctx); 925 ngx_resolve_name_done(ctx);
926 ur->ctx = NULL; 926 ur->ctx = NULL;
927 927
928 ngx_http_upstream_connect(r, u); 928 ngx_http_upstream_connect(r, u);
929
930 failed:
931
932 ngx_http_run_posted_requests(r->connection);
929 } 933 }
930 934
931 935
932 static void 936 static void
933 ngx_http_upstream_handler(ngx_event_t *ev) 937 ngx_http_upstream_handler(ngx_event_t *ev)