Welcome! Log In Create A New Profile

Advanced

[nginx] Resolver: simplified ngx_resolver_copy().

Maxim Dounin
May 25, 2021 11:34AM
details: https://hg.nginx.org/nginx/rev/4ebe1251a8c3
branches:
changeset: 7853:4ebe1251a8c3
user: Maxim Dounin <mdounin@mdounin.ru>
date: Tue May 25 15:17:45 2021 +0300
description:
Resolver: simplified ngx_resolver_copy().

Instead of checking on each label if we need to place a dot or not,
now it always adds a dot after a label, and reduces the resulting
length afterwards.

diffstat:

src/core/ngx_resolver.c | 13 +++++--------
1 files changed, 5 insertions(+), 8 deletions(-)

diffs (50 lines):

diff -r 771743838cbd -r 4ebe1251a8c3 src/core/ngx_resolver.c
--- a/src/core/ngx_resolver.c Tue May 25 15:17:43 2021 +0300
+++ b/src/core/ngx_resolver.c Tue May 25 15:17:45 2021 +0300
@@ -3939,11 +3939,11 @@ ngx_resolver_copy(ngx_resolver_t *r, ngx
{
char *err;
u_char *p, *dst;
- ssize_t len;
+ size_t len;
ngx_uint_t i, n;

p = src;
- len = -1;
+ len = 0;

/*
* compression pointers allow to create endless loop, so we set limit;
@@ -3996,7 +3996,7 @@ done:
return NGX_OK;
}

- if (len == -1) {
+ if (len == 0) {
ngx_str_null(name);
return NGX_OK;
}
@@ -4012,7 +4012,7 @@ done:
n = *src++;

if (n == 0) {
- name->len = dst - name->data;
+ name->len = dst - name->data - 1;
return NGX_OK;
}

@@ -4021,13 +4021,10 @@ done:
src = &buf[n];

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

[nginx] Resolver: simplified ngx_resolver_copy().

Maxim Dounin 150 May 25, 2021 11:34AM



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

Online Users

Guests: 65
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