Welcome! Log In Create A New Profile

Advanced

[nginx] Resolver: reworked ngx_resolver_copy() copy loop.

Maxim Dounin
May 25, 2021 11:36AM
details: https://hg.nginx.org/nginx/rev/0b884e47bb79
branches: stable-1.20
changeset: 7861:0b884e47bb79
user: Maxim Dounin <mdounin@mdounin.ru>
date: Tue May 25 15:17:43 2021 +0300
description:
Resolver: reworked ngx_resolver_copy() copy loop.

To make the code easier to read, reworked the ngx_resolver_copy()
copy loop to match the one used to calculate length. No functional
changes.

diffstat:

src/core/ngx_resolver.c | 18 +++++++-----------
1 files changed, 7 insertions(+), 11 deletions(-)

diffs (40 lines):

diff -r a45b6a206cfc -r 0b884e47bb79 src/core/ngx_resolver.c
--- a/src/core/ngx_resolver.c Tue May 25 15:17:41 2021 +0300
+++ b/src/core/ngx_resolver.c Tue May 25 15:17:43 2021 +0300
@@ -4008,15 +4008,18 @@ done:

name->data = dst;

- n = *src++;
-
for ( ;; ) {
+ n = *src++;
+
+ if (n == 0) {
+ name->len = dst - name->data;
+ return NGX_OK;
+ }
+
if (n & 0xc0) {
n = ((n & 0x3f) << 8) + *src;
src = &buf[n];

- n = *src++;
-
} else {
if (dst != name->data) {
*dst++ = '.';
@@ -4025,13 +4028,6 @@ done:
ngx_strlow(dst, src, n);
dst += n;
src += n;
-
- n = *src++;
- }
-
- if (n == 0) {
- name->len = dst - name->data;
- return NGX_OK;
}
}
}
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[nginx] Resolver: reworked ngx_resolver_copy() copy loop.

Maxim Dounin 115 May 25, 2021 11:36AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 73
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready