[nginx] Upstream: optimize loops in ngx_http_upstream_init_round...
Maxim Dounin
mdounin at mdounin.ru
Mon Oct 21 14:38:18 UTC 2013
details: http://hg.nginx.org/nginx/rev/e6a1623f87bc
branches:
changeset: 5429:e6a1623f87bc
user: Xiaochen Wang <wangxiaochen0 at gmail.com>
date: Mon Oct 21 18:20:32 2013 +0800
description:
Upstream: optimize loops in ngx_http_upstream_init_round_robin().
diffstat:
src/http/ngx_http_upstream_round_robin.c | 16 ++++++++--------
1 files changed, 8 insertions(+), 8 deletions(-)
diffs (35 lines):
diff --git a/src/http/ngx_http_upstream_round_robin.c b/src/http/ngx_http_upstream_round_robin.c
--- a/src/http/ngx_http_upstream_round_robin.c
+++ b/src/http/ngx_http_upstream_round_robin.c
@@ -71,11 +71,11 @@ ngx_http_upstream_init_round_robin(ngx_c
n = 0;
for (i = 0; i < us->servers->nelts; i++) {
+ if (server[i].backup) {
+ continue;
+ }
+
for (j = 0; j < server[i].naddrs; j++) {
- if (server[i].backup) {
- continue;
- }
-
peers->peer[n].sockaddr = server[i].addrs[j].sockaddr;
peers->peer[n].socklen = server[i].addrs[j].socklen;
peers->peer[n].name = server[i].addrs[j].name;
@@ -125,11 +125,11 @@ ngx_http_upstream_init_round_robin(ngx_c
n = 0;
for (i = 0; i < us->servers->nelts; i++) {
+ if (!server[i].backup) {
+ continue;
+ }
+
for (j = 0; j < server[i].naddrs; j++) {
- if (!server[i].backup) {
- continue;
- }
-
backup->peer[n].sockaddr = server[i].addrs[j].sockaddr;
backup->peer[n].socklen = server[i].addrs[j].socklen;
backup->peer[n].name = server[i].addrs[j].name;
More information about the nginx-devel
mailing list