Skip to content

Commit

Permalink
Upstream: call ngx_http_run_posted_requests() on resolve errors.
Browse files Browse the repository at this point in the history
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.


git-svn-id: svn://svn.nginx.org/nginx/trunk@5113 73f98a42-aea0-e011-b76d-00259023448c
  • Loading branch information
mdounin committed Mar 14, 2013
1 parent 9acfc57 commit 2b2bb4a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/http/ngx_http_upstream.c
Expand Up @@ -894,7 +894,7 @@ ngx_http_upstream_resolve_handler(ngx_resolver_ctx_t *ctx)
ngx_resolver_strerror(ctx->state));

ngx_http_upstream_finalize_request(r, u, NGX_HTTP_BAD_GATEWAY);
return;
goto failed;
}

ur->naddrs = ctx->naddrs;
Expand All @@ -919,13 +919,17 @@ ngx_http_upstream_resolve_handler(ngx_resolver_ctx_t *ctx)
if (ngx_http_upstream_create_round_robin_peer(r, ur) != NGX_OK) {
ngx_http_upstream_finalize_request(r, u,
NGX_HTTP_INTERNAL_SERVER_ERROR);
return;
goto failed;
}

ngx_resolve_name_done(ctx);
ur->ctx = NULL;

ngx_http_upstream_connect(r, u);

failed:

ngx_http_run_posted_requests(r->connection);
}


Expand Down

0 comments on commit 2b2bb4a

Please sign in to comment.