Skip to content

Commit

Permalink
Improve handling of overlapping aliases in APP commands
Browse files Browse the repository at this point in the history
Resolves MODCLUSTER-824
  • Loading branch information
jajik committed Oct 17, 2024
1 parent 885fdb0 commit fea3021
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions native/mod_manager/mod_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -2075,7 +2075,7 @@ static char *process_appl_cmd(request_rec *r, char **ptr, int status, int *errty

int i = 0;
hostinfo_t hostinfo;
hostinfo_t *host;
hostinfo_t *host = NULL;
char *err_msg;

memset(&nodeinfo.mess, '\0', sizeof(nodeinfo.mess));
Expand Down Expand Up @@ -2149,22 +2149,29 @@ static char *process_appl_cmd(request_rec *r, char **ptr, int status, int *errty
return ret;
}

/* Read the ID of the virtual host corresponding to the first Alias */
/* Go through the provided Aliases, the first Alias that matches an existing host gets used
* otherwise, a new host will be created
*/
hostinfo.node = node->mess.id;
hostinfo.id = 0;
if (vhost->host != NULL) {
char *s = hostinfo.host;
unsigned j = 1;
strncpy(hostinfo.host, vhost->host, HOSTALIASZ);
while (*s != '\0' && *s != ',' && j < sizeof(hostinfo.host)) {
j++;
s++;
int start = 0;
i = 0;
while (host == NULL && i + start < strlen(vhost->host)) {
while (vhost->host[start + i] != ',' && vhost->host[start + i] != '\0') {
i++;
}

strncpy(hostinfo.host, vhost->host + start, i);
hostinfo.host[i] = '\0';
host = read_host(hoststatsmem, &hostinfo);
start = start + i + 1;
i = 0;
}
*s = '\0';
} else {
hostinfo.host[0] = '\0';
}
hostinfo.id = 0;
host = read_host(hoststatsmem, &hostinfo);

if (host == NULL) {
int vid, size, *id;

Expand Down

0 comments on commit fea3021

Please sign in to comment.