changeset 6360:93d70d87914c stable-1.8

Resolver: limited CNAME recursion. Previously, the recursion was only limited for cached responses.
author Ruslan Ermilov <ru@nginx.com>
date Tue, 26 Jan 2016 16:47:14 +0300
parents dac6eda40475
children 5959efb40b07
files src/core/ngx_resolver.c
diffstat 1 files changed, 22 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/core/ngx_resolver.c
+++ b/src/core/ngx_resolver.c
@@ -1981,11 +1981,33 @@ ngx_resolver_process_a(ngx_resolver_t *r
 
         ngx_queue_insert_head(&r->name_expire_queue, &rn->queue);
 
+        ngx_resolver_free(r, rn->query);
+        rn->query = NULL;
+#if (NGX_HAVE_INET6)
+        rn->query6 = NULL;
+#endif
+
         ctx = rn->waiting;
         rn->waiting = NULL;
 
         if (ctx) {
 
+            if (ctx->recursion++ >= NGX_RESOLVER_MAX_RECURSION) {
+
+                /* unlock name mutex */
+
+                do {
+                    ctx->state = NGX_RESOLVE_NXDOMAIN;
+                    next = ctx->next;
+
+                    ctx->handler(ctx);
+
+                    ctx = next;
+                } while (ctx);
+
+                return;
+            }
+
             for (next = ctx; next; next = next->next) {
                 next->node = NULL;
             }
@@ -1993,12 +2015,6 @@ ngx_resolver_process_a(ngx_resolver_t *r
             (void) ngx_resolve_name_locked(r, ctx, &name);
         }
 
-        ngx_resolver_free(r, rn->query);
-        rn->query = NULL;
-#if (NGX_HAVE_INET6)
-        rn->query6 = NULL;
-#endif
-
         /* unlock name mutex */
 
         return;