@@ -2084,7 +2084,7 @@ static char *process_appl_cmd(request_rec *r, char **ptr, int status, int *errty
2084
2084
2085
2085
int i = 0 ;
2086
2086
hostinfo_t hostinfo ;
2087
- hostinfo_t * host ;
2087
+ hostinfo_t * host = NULL ;
2088
2088
char * err_msg ;
2089
2089
2090
2090
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
2158
2158
return ret ;
2159
2159
}
2160
2160
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
+ */
2162
2164
hostinfo .node = node -> mess .id ;
2165
+ hostinfo .id = 0 ;
2163
2166
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
+ }
2172
2180
} else {
2173
2181
hostinfo .host [0 ] = '\0' ;
2174
2182
}
2175
- hostinfo .id = 0 ;
2176
- host = read_host (hoststatsmem , & hostinfo );
2183
+
2177
2184
if (host == NULL ) {
2178
2185
int vid , size , * id ;
2179
2186
0 commit comments