nginx-module-vts
nginx-module-vts copied to clipboard
fixbug: can not obtain all address statuses after the upstream domain name is resolved when using control interface
code should be motified, see below:
diff --git a/src/ngx_http_vhost_traffic_status_control.c b/src/ngx_http_vhost_traffic_status_control.c
index 7b7222f..66da8f1 100644
--- a/src/ngx_http_vhost_traffic_status_control.c
+++ b/src/ngx_http_vhost_traffic_status_control.c
@@ -44,7 +44,7 @@ ngx_http_vhost_traffic_status_node_upstream_lookup(
{
ngx_int_t rc;
ngx_str_t key, usg, ush;
- ngx_uint_t i, j;
+ ngx_uint_t i, j, k;
ngx_http_upstream_server_t *us;
ngx_http_upstream_srv_conf_t *uscf, **uscfp;
ngx_http_upstream_main_conf_t *umcf;
@@ -99,18 +99,20 @@ ngx_http_vhost_traffic_status_node_upstream_lookup(
if (ngx_strncmp(uscf->host.data, usg.data, usg.len) == 0) {
for (j = 0; j < uscf->servers->nelts; j++) {
- if (us[j].addrs->name.len == ush.len) {
- if (ngx_strncmp(us[j].addrs->name.data, ush.data, ush.len) == 0) {
- *usn = us[j];
+ for (k = 0; k < us[j].naddrs; k++) {
+ if (us[j].addrs[k].name.len == ush.len) {
+ if (ngx_strncmp(us[j].addrs[k].name.data, ush.data, ush.len) == 0) {
+ *usn = us[j];
#if nginx_version > 1007001
- usn->name = us[j].addrs->name;
+ usn->name = us[j].addrs[k].name;
#endif
-
- control->count++;
- break;
- }
- }
+
+ control->count++;
+ break;
+ }
+ }
+ }
}
break;
@alexzzh Thanks! We are admirable that you try to fix something to happen in your usecase and cooperate this OSS project. Well at first, we’d like to clarify what do you resolve an issue, please tell us the behavior of this issue, the nginx.conf which can reproduce the behavior at least🙏