Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixbug: can not obtain all address statuses after the upstream domain name is resolved when using control interface #259

Open
alexzzh opened this issue Feb 17, 2023 · 2 comments

Comments

@alexzzh
Copy link

alexzzh commented Feb 17, 2023

No description provided.

@alexzzh
Copy link
Author

alexzzh commented Feb 17, 2023

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 alexzzh changed the title fixbug-修复vts模块control接口不能获取到upstream域名解析后的所有地址状态 fixbug-can-not-obtain-all-address-statuses-after-the-upstream-domain-name-is-resolved-using-control-interface Feb 17, 2023
@alexzzh alexzzh changed the title fixbug-can-not-obtain-all-address-statuses-after-the-upstream-domain-name-is-resolved-using-control-interface fixbug: can not obtain all address statuses after the upstream domain name is resolved when using control interface Feb 17, 2023
@u5surf
Copy link
Collaborator

u5surf commented Feb 17, 2023

@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🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants