@@ -2084,7 +2084,7 @@ static char *process_appl_cmd(request_rec *r, char **ptr, int status, int *errty
20842084
20852085 int i = 0 ;
20862086 hostinfo_t hostinfo ;
2087- hostinfo_t * host ;
2087+ hostinfo_t * host = NULL ;
20882088 char * err_msg ;
20892089
20902090 memset (& nodeinfo .mess , '\0' , sizeof (nodeinfo .mess ));
@@ -2158,22 +2158,29 @@ static char *process_appl_cmd(request_rec *r, char **ptr, int status, int *errty
21582158 return ret ;
21592159 }
21602160
2161- /* Read the ID of the virtual host corresponding to the first Alias */
2161+ /* Go through the provided Aliases, the first Alias that matches an existing host gets used
2162+ * otherwise, a new host will be created
2163+ */
21622164 hostinfo .node = node -> mess .id ;
2165+ hostinfo .id = 0 ;
21632166 if (vhost -> host != NULL ) {
2164- char * s = hostinfo .host ;
2165- unsigned j = 1 ;
2166- strncpy (hostinfo .host , vhost -> host , HOSTALIASZ );
2167- while (* s != '\0' && * s != ',' && j < sizeof (hostinfo .host )) {
2168- j ++ ;
2169- s ++ ;
2170- }
2171- * s = '\0' ;
2167+ int start = 0 ;
2168+ i = 0 ;
2169+ while (host == NULL && i + start < strlen (vhost -> host )) {
2170+ while (vhost -> host [start + i ] != ',' && vhost -> host [start + i ] != '\0' ) {
2171+ i ++ ;
2172+ }
2173+
2174+ strncpy (hostinfo .host , vhost -> host + start , i );
2175+ hostinfo .host [i ] = '\0' ;
2176+ host = read_host (hoststatsmem , & hostinfo );
2177+ start = start + i + 1 ;
2178+ i = 0 ;
2179+ }
21722180 } else {
21732181 hostinfo .host [0 ] = '\0' ;
21742182 }
2175- hostinfo .id = 0 ;
2176- host = read_host (hoststatsmem , & hostinfo );
2183+
21772184 if (host == NULL ) {
21782185 int vid , size , * id ;
21792186
0 commit comments