[nginx] svn commit: r5113 - trunk/src/http

mdounin at mdounin.ru mdounin at mdounin.ru
Thu Mar 14 12:37:54 UTC 2013


Author: mdounin
Date: 2013-03-14 12:37:54 +0000 (Thu, 14 Mar 2013)
New Revision: 5113
URL: http://trac.nginx.org/nginx/changeset/5113/nginx

Log:
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.


Modified:
   trunk/src/http/ngx_http_upstream.c

Modified: trunk/src/http/ngx_http_upstream.c
===================================================================
--- trunk/src/http/ngx_http_upstream.c	2013-03-14 12:30:26 UTC (rev 5112)
+++ trunk/src/http/ngx_http_upstream.c	2013-03-14 12:37:54 UTC (rev 5113)
@@ -894,7 +894,7 @@
                       ngx_resolver_strerror(ctx->state));
 
         ngx_http_upstream_finalize_request(r, u, NGX_HTTP_BAD_GATEWAY);
-        return;
+        goto failed;
     }
 
     ur->naddrs = ctx->naddrs;
@@ -919,13 +919,17 @@
     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);
 }
 
 



More information about the nginx-devel mailing list