-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnginx-1.6.3-Resolver-fix-CNAME-processing.patch
80 lines (66 loc) · 2.27 KB
/
nginx-1.6.3-Resolver-fix-CNAME-processing.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
exporting patch:
# HG changeset patch
# User Ruslan Ermilov <[email protected]>
# Date 1453815998 -10800
# Tue Jan 26 16:46:38 2016 +0300
# Branch stable-1.8
# Node ID 838946300825379ccdd3acfb131cf66d6ae3cb85
# Parent f63dd04c158062d73fcb6aff59124910fa1fae75
Resolver: fixed CNAME processing for several requests.
When several requests were waiting for a response, then after getting
a CNAME response only the last request was properly processed, while
others were left waiting.
diff -r f63dd04c1580 -r 838946300825 src/core/ngx_resolver.c
--- a/src/core/ngx_resolver.c Tue Jan 26 16:46:31 2016 +0300
+++ b/src/core/ngx_resolver.c Tue Jan 26 16:46:38 2016 +0300
@@ -473,7 +473,7 @@
ngx_int_t rc;
ngx_uint_t naddrs;
ngx_addr_t *addrs;
- ngx_resolver_ctx_t *next;
+ ngx_resolver_ctx_t *next, *last;
ngx_resolver_node_t *rn;
ngx_strlow(ctx->name.data, ctx->name.data, ctx->name.len);
@@ -484,6 +484,9 @@
if (rn) {
+ /* ctx can be a list after NGX_RESOLVE_CNAME */
+ for (last = ctx; last->next; last = last->next);
+
if (rn->valid >= ngx_time()) {
ngx_log_debug0(NGX_LOG_DEBUG_CORE, r->log, 0, "resolve cached");
@@ -511,7 +514,7 @@
}
}
- ctx->next = rn->waiting;
+ last->next = rn->waiting;
rn->waiting = NULL;
/* unlock name mutex */
@@ -557,7 +560,7 @@
return ngx_resolve_name_locked(r, ctx);
}
- ctx->next = rn->waiting;
+ last->next = rn->waiting;
rn->waiting = NULL;
/* unlock name mutex */
@@ -590,7 +593,7 @@
ngx_add_timer(ctx->event, ctx->timeout);
}
- ctx->next = rn->waiting;
+ last->next = rn->waiting;
rn->waiting = ctx;
ctx->state = NGX_AGAIN;
@@ -661,8 +664,14 @@
ngx_resolver_free(r, rn->name);
ngx_resolver_free(r, rn);
- ctx->state = NGX_RESOLVE_NXDOMAIN;
- ctx->handler(ctx);
+ do {
+ ctx->state = NGX_RESOLVE_NXDOMAIN;
+ next = ctx->next;
+
+ ctx->handler(ctx);
+
+ ctx = next;
+ } while (ctx);
return NGX_OK;
}