<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p style="margin-top:0;margin-bottom:0"></p>
<div># HG changeset patch</div>
<div># User Johan Ekenlycka <johan.ekenlycka@gmail.com></div>
<div># Date 1537270510 -7200</div>
<div># Tue Sep 18 13:35:10 2018 +0200</div>
<div># Node ID f6a4b9360aaa102749233e14d4b49120dae46d9b</div>
<div># Parent 87d2ea860f380dc8418c97c0163412f53c2d008e</div>
<div>Fix copy of multiple peers when using upstream zone</div>
<div><br>
</div>
<div>Iteration of destination pointer and next pointer on peers was</div>
<div>not performed correctly, resulting in NULL peers when multiple</div>
<div>peers in upstream.</div>
<div><br>
</div>
<div>diff -r 87d2ea860f38 -r f6a4b9360aaa src/http/modules/ngx_http_upstream_zone_module.c</div>
<div>--- a/src/http/modules/ngx_http_upstream_zone_module.c<span style="white-space:pre">
</span>Mon Sep 10 18:57:39 2018 +0300</div>
<div>+++ b/src/http/modules/ngx_http_upstream_zone_module.c<span style="white-space:pre">
</span>Tue Sep 18 13:35:10 2018 +0200</div>
<div>@@ -187,8 +187,9 @@</div>
<div> ngx_http_upstream_zone_copy_peers(ngx_slab_pool_t *shpool,</div>
<div> ngx_http_upstream_srv_conf_t *uscf)</div>
<div> {</div>
<div>+ ngx_uint_t i;</div>
<div> ngx_str_t *name;</div>
<div>- ngx_http_upstream_rr_peer_t *peer, **peerp;</div>
<div>+ ngx_http_upstream_rr_peer_t *peer;</div>
<div> ngx_http_upstream_rr_peers_t *peers, *backup;</div>
<div> </div>
<div> peers = ngx_slab_alloc(shpool, sizeof(ngx_http_upstream_rr_peers_t));</div>
<div>@@ -215,14 +216,17 @@</div>
<div> </div>
<div> peers->shpool = shpool;</div>
<div> </div>
<div>- for (peerp = &peers->peer; *peerp; peerp = &peer->next) {</div>
<div>+ for (i = 0; i < peers->number; i++) {</div>
<div> /* pool is unlocked */</div>
<div>- peer = ngx_http_upstream_zone_copy_peer(peers, *peerp);</div>
<div>+ peer = ngx_http_upstream_zone_copy_peer(peers, &peers->peer[i]);</div>
<div> if (peer == NULL) {</div>
<div> return NULL;</div>
<div> }</div>
<div>+ if (i > 0) {</div>
<div>+ peers->peer[i - 1].next = peer;</div>
<div>+ }</div>
<div> </div>
<div>- *peerp = peer;</div>
<div>+ peers->peer[i] = *peer;</div>
<div> }</div>
<div> </div>
<div> if (peers->next == NULL) {</div>
<div>@@ -240,14 +244,18 @@</div>
<div> </div>
<div> backup->shpool = shpool;</div>
<div> </div>
<div>- for (peerp = &backup->peer; *peerp; peerp = &peer->next) {</div>
<div>+</div>
<div>+ for (i = 0; i < backup->number; i++) {</div>
<div> /* pool is unlocked */</div>
<div>- peer = ngx_http_upstream_zone_copy_peer(backup, *peerp);</div>
<div>+ peer = ngx_http_upstream_zone_copy_peer(backup, &backup->peer[i]);</div>
<div> if (peer == NULL) {</div>
<div> return NULL;</div>
<div> }</div>
<div>+ if (i > 0) {</div>
<div>+ backup->peer[i - 1].next = peer;</div>
<div>+ }</div>
<div> </div>
<div>- *peerp = peer;</div>
<div>+ backup->peer[i] = *peer;</div>
<div> }</div>
<div> </div>
<div> peers->next = backup;</div>
<br>
<p></p>
</div>
</body>
</html>