@@ -490,14 +490,6 @@ static const struct domain_storage_method domain_storage = {
490
490
};
491
491
/* clang-format on */
492
492
493
- /* helper for the handling of the Alias: host1,... Context: context1,... */
494
- struct cluster_host
495
- {
496
- char * host ;
497
- char * context ;
498
- struct cluster_host * next ;
499
- };
500
-
501
493
/*
502
494
* cleanup logic
503
495
*/
@@ -1267,13 +1259,13 @@ static int check_context_alias_length(const char *str, int limit)
1267
1259
* 2) during APP command
1268
1260
* to differenciate between the two use the last argument (true -> CONFIG, false -> APP)
1269
1261
*/
1270
- static char * process_context_alias (char * key , char * val , apr_pool_t * p , struct cluster_host * phost , int * errtype ,
1262
+ static char * process_context_alias (char * key , char * val , apr_pool_t * p , char * * contexts , char * * aliases , int * errtype ,
1271
1263
int in_config )
1272
1264
{
1273
1265
if (strcasecmp (key , "Alias" ) == 0 ) {
1274
1266
char * tmp ;
1275
1267
1276
- if (phost -> host && !in_config ) {
1268
+ if (* aliases && !in_config ) {
1277
1269
* errtype = TYPESYNTAX ;
1278
1270
return in_config ? SALIBAD : SMULALB ;
1279
1271
}
@@ -1289,15 +1281,15 @@ static char *process_context_alias(char *key, char *val, apr_pool_t *p, struct c
1289
1281
tmp ++ ;
1290
1282
}
1291
1283
1292
- if (phost -> host ) {
1293
- phost -> host = apr_pstrcat (p , phost -> host , "," , val , NULL );
1284
+ if (* aliases ) {
1285
+ * aliases = apr_pstrcat (p , * aliases , "," , val , NULL );
1294
1286
} else {
1295
- phost -> host = val ;
1287
+ * aliases = val ;
1296
1288
}
1297
1289
}
1298
1290
1299
1291
if (strcasecmp (key , "Context" ) == 0 ) {
1300
- if (phost -> context && !in_config ) {
1292
+ if (* contexts && !in_config ) {
1301
1293
* errtype = TYPESYNTAX ;
1302
1294
return SMULCTB ;
1303
1295
}
@@ -1306,10 +1298,10 @@ static char *process_context_alias(char *key, char *val, apr_pool_t *p, struct c
1306
1298
return SCONBIG ;
1307
1299
}
1308
1300
1309
- if (phost -> context ) {
1310
- phost -> context = apr_pstrcat (p , phost -> context , "," , val , NULL );
1301
+ if (* contexts ) {
1302
+ * contexts = apr_pstrcat (p , * contexts , "," , val , NULL );
1311
1303
} else {
1312
- phost -> context = val ;
1304
+ * contexts = val ;
1313
1305
}
1314
1306
}
1315
1307
@@ -1342,8 +1334,8 @@ static char *process_config(request_rec *r, char **ptr, int *errtype)
1342
1334
nodeinfo_t * node ;
1343
1335
balancerinfo_t balancerinfo ;
1344
1336
1345
- struct cluster_host * vhost ;
1346
- struct cluster_host * phost ;
1337
+ char * contexts = NULL ;
1338
+ char * aliases = NULL ;
1347
1339
1348
1340
int i = 0 ;
1349
1341
int id = -1 ;
@@ -1356,14 +1348,6 @@ static char *process_config(request_rec *r, char **ptr, int *errtype)
1356
1348
const proxy_server_conf * the_conf = NULL ;
1357
1349
apr_status_t rv ;
1358
1350
1359
- vhost = apr_palloc (r -> pool , sizeof (struct cluster_host ));
1360
-
1361
- /* Map nothing by default */
1362
- vhost -> host = NULL ;
1363
- vhost -> context = NULL ;
1364
- vhost -> next = NULL ;
1365
- phost = vhost ;
1366
-
1367
1351
/* Fill default node values */
1368
1352
process_config_node_defaults (r , & nodeinfo , mconf );
1369
1353
ap_log_error (APLOG_MARK , APLOG_DEBUG , 0 , r -> server , "process_config: Start" );
@@ -1389,7 +1373,7 @@ static char *process_config(request_rec *r, char **ptr, int *errtype)
1389
1373
return err_msg ;
1390
1374
}
1391
1375
/* Optional parameters */
1392
- err_msg = process_context_alias (ptr [i ], ptr [i + 1 ], r -> pool , phost , errtype , 1 );
1376
+ err_msg = process_context_alias (ptr [i ], ptr [i + 1 ], r -> pool , & contexts , & aliases , errtype , 1 );
1393
1377
if (err_msg != NULL ) {
1394
1378
return err_msg ;
1395
1379
}
@@ -1580,8 +1564,7 @@ static char *process_config(request_rec *r, char **ptr, int *errtype)
1580
1564
inc_version_node ();
1581
1565
1582
1566
/* Insert the Alias and corresponding Context */
1583
- phost = vhost ;
1584
- if (phost -> host == NULL && phost -> context == NULL ) {
1567
+ if (aliases == NULL && contexts == NULL ) {
1585
1568
/* if using mod_balancer create or update the worker */
1586
1569
if (balancer_manage ) {
1587
1570
apr_status_t rv = mod_manager_manage_worker (r , & nodeinfo , & balancerinfo );
@@ -1592,19 +1575,20 @@ static char *process_config(request_rec *r, char **ptr, int *errtype)
1592
1575
loc_unlock_nodes ();
1593
1576
return NULL ; /* Alias and Context missing */
1594
1577
}
1595
- while (phost ) {
1596
- if (insert_update_hosts (r -> server , hoststatsmem , phost -> host , id , vid ) != APR_SUCCESS ) {
1597
- loc_unlock_nodes ();
1598
- return apr_psprintf (r -> pool , MHOSTUI , nodeinfo .mess .JVMRoute );
1599
- }
1600
- if (insert_update_contexts (r -> server , contextstatsmem , phost -> context , id , vid , STOPPED ) != APR_SUCCESS ) {
1601
- loc_unlock_nodes ();
1602
- return apr_psprintf (r -> pool , MCONTUI , nodeinfo .mess .JVMRoute );
1603
- }
1604
- phost = phost -> next ;
1605
- vid ++ ;
1578
+
1579
+
1580
+ if (insert_update_hosts (r -> server , hoststatsmem , aliases , id , vid ) != APR_SUCCESS ) {
1581
+ loc_unlock_nodes ();
1582
+ return apr_psprintf (r -> pool , MHOSTUI , nodeinfo .mess .JVMRoute );
1606
1583
}
1607
1584
1585
+ if (insert_update_contexts (r -> server , contextstatsmem , contexts , id , vid , STOPPED ) != APR_SUCCESS ) {
1586
+ loc_unlock_nodes ();
1587
+ return apr_psprintf (r -> pool , MCONTUI , nodeinfo .mess .JVMRoute );
1588
+ }
1589
+
1590
+ vid ++ ;
1591
+
1608
1592
/* if using mod_balancer create or update the worker */
1609
1593
if (balancer_manage ) {
1610
1594
apr_status_t rv = mod_manager_manage_worker (r , & nodeinfo , & balancerinfo );
@@ -2098,19 +2082,16 @@ static char *process_appl_cmd(request_rec *r, char **ptr, int status, int *errty
2098
2082
{
2099
2083
nodeinfo_t nodeinfo ;
2100
2084
nodeinfo_t * node ;
2101
- struct cluster_host * vhost ;
2085
+
2086
+ char * contexts = NULL ;
2087
+ char * aliases = NULL ;
2102
2088
2103
2089
int i = 0 ;
2104
2090
hostinfo_t hostinfo ;
2105
2091
hostinfo_t * host = NULL ;
2106
2092
char * err_msg ;
2107
2093
2108
2094
memset (& nodeinfo .mess , '\0' , sizeof (nodeinfo .mess ));
2109
- /* Map nothing by default */
2110
- vhost = apr_palloc (r -> pool , sizeof (struct cluster_host ));
2111
- vhost -> host = NULL ;
2112
- vhost -> context = NULL ;
2113
- vhost -> next = NULL ;
2114
2095
2115
2096
while (ptr [i ]) {
2116
2097
if (strcasecmp (ptr [i ], "JVMRoute" ) == 0 ) {
@@ -2121,7 +2102,7 @@ static char *process_appl_cmd(request_rec *r, char **ptr, int status, int *errty
2121
2102
strcpy (nodeinfo .mess .JVMRoute , ptr [i + 1 ]);
2122
2103
nodeinfo .mess .id = -1 ;
2123
2104
}
2124
- err_msg = process_context_alias (ptr [i ], ptr [i + 1 ], r -> pool , vhost , errtype , 0 );
2105
+ err_msg = process_context_alias (ptr [i ], ptr [i + 1 ], r -> pool , & contexts , & aliases , errtype , 0 );
2125
2106
if (err_msg ) {
2126
2107
return err_msg ;
2127
2108
}
@@ -2136,16 +2117,16 @@ static char *process_appl_cmd(request_rec *r, char **ptr, int status, int *errty
2136
2117
}
2137
2118
2138
2119
/* Note: This applies only for non-wildcarded requests for which Alias and Context are required */
2139
- if (vhost -> context == NULL && vhost -> host == NULL && strcmp (r -> uri , "/*" ) != 0 ) {
2120
+ if (contexts == NULL && aliases == NULL && strcmp (r -> uri , "/*" ) != 0 ) {
2140
2121
* errtype = TYPESYNTAX ;
2141
2122
return NOCONAL ;
2142
2123
}
2143
2124
2144
- if (vhost -> context == NULL && vhost -> host != NULL ) {
2125
+ if (contexts == NULL && aliases != NULL ) {
2145
2126
* errtype = TYPESYNTAX ;
2146
2127
return SALIBAD ;
2147
2128
}
2148
- if (vhost -> host == NULL && vhost -> context != NULL ) {
2129
+ if (aliases == NULL && contexts != NULL ) {
2149
2130
* errtype = TYPESYNTAX ;
2150
2131
return SCONBAD ;
2151
2132
}
@@ -2188,15 +2169,15 @@ static char *process_appl_cmd(request_rec *r, char **ptr, int status, int *errty
2188
2169
*/
2189
2170
hostinfo .node = node -> mess .id ;
2190
2171
hostinfo .id = 0 ;
2191
- if (vhost -> host != NULL ) {
2172
+ if (aliases != NULL ) {
2192
2173
int start = 0 ;
2193
2174
i = 0 ;
2194
- while (host == NULL && (unsigned )(i + start ) < strlen (vhost -> host )) {
2195
- while (vhost -> host [start + i ] != ',' && vhost -> host [start + i ] != '\0' ) {
2175
+ while (host == NULL && (unsigned )(i + start ) < strlen (aliases )) {
2176
+ while (aliases [start + i ] != ',' && aliases [start + i ] != '\0' ) {
2196
2177
i ++ ;
2197
2178
}
2198
2179
2199
- strncpy (hostinfo .host , vhost -> host + start , i );
2180
+ strncpy (hostinfo .host , aliases + start , i );
2200
2181
hostinfo .host [i ] = '\0' ;
2201
2182
host = read_host (hoststatsmem , & hostinfo );
2202
2183
start = start + i + 1 ;
@@ -2233,16 +2214,16 @@ static char *process_appl_cmd(request_rec *r, char **ptr, int status, int *errty
2233
2214
ap_log_error (APLOG_MARK , APLOG_DEBUG , 0 , r -> server , "process_appl_cmd: adding vhost: %d node: %d route: %s" ,
2234
2215
vid , node -> mess .id , nodeinfo .mess .JVMRoute );
2235
2216
/* If the Host doesn't exist yet create it */
2236
- if (insert_update_hosts (r -> server , hoststatsmem , vhost -> host , node -> mess .id , vid ) != APR_SUCCESS ) {
2217
+ if (insert_update_hosts (r -> server , hoststatsmem , aliases , node -> mess .id , vid ) != APR_SUCCESS ) {
2237
2218
loc_unlock_nodes ();
2238
2219
* errtype = TYPEMEM ;
2239
2220
return apr_psprintf (r -> pool , MHOSTUI , nodeinfo .mess .JVMRoute );
2240
2221
}
2241
2222
hostinfo .id = 0 ;
2242
2223
hostinfo .node = node -> mess .id ;
2243
2224
hostinfo .host [0 ] = '\0' ;
2244
- if (vhost -> host != NULL ) {
2245
- strncpy (hostinfo .host , vhost -> host , sizeof (hostinfo .host ));
2225
+ if (aliases != NULL ) {
2226
+ strncpy (hostinfo .host , aliases , sizeof (hostinfo .host ));
2246
2227
hostinfo .host [sizeof (hostinfo .host ) - 1 ] = '\0' ;
2247
2228
}
2248
2229
@@ -2264,7 +2245,7 @@ static char *process_appl_cmd(request_rec *r, char **ptr, int status, int *errty
2264
2245
if (get_context (contextstatsmem , & ou , id [i ]) != APR_SUCCESS ) {
2265
2246
continue ;
2266
2247
}
2267
- if (strcmp (ou -> context , vhost -> context ) == 0 ) {
2248
+ if (strcmp (ou -> context , contexts ) == 0 ) {
2268
2249
/* There is the same context somewhere else */
2269
2250
nodeinfo_t * hisnode ;
2270
2251
if (get_node (nodestatsmem , & hisnode , ou -> node ) != APR_SUCCESS ) {
@@ -2273,22 +2254,22 @@ static char *process_appl_cmd(request_rec *r, char **ptr, int status, int *errty
2273
2254
if (strcmp (hisnode -> mess .balancer , node -> mess .balancer )) {
2274
2255
/* the same context would be on 2 different balancer */
2275
2256
ap_log_error (APLOG_MARK , APLOG_WARNING , 0 , r -> server ,
2276
- "process_appl_cmd: ENABLE: context %s is in balancer %s and %s" , vhost -> context ,
2257
+ "process_appl_cmd: ENABLE: context %s is in balancer %s and %s" , contexts ,
2277
2258
node -> mess .balancer , hisnode -> mess .balancer );
2278
2259
}
2279
2260
}
2280
2261
}
2281
2262
}
2282
2263
2283
2264
/* Now update each context from Context: part */
2284
- if (insert_update_contexts (r -> server , contextstatsmem , vhost -> context , node -> mess .id , host -> vhost , status ) !=
2265
+ if (insert_update_contexts (r -> server , contextstatsmem , contexts , node -> mess .id , host -> vhost , status ) !=
2285
2266
APR_SUCCESS ) {
2286
2267
loc_unlock_nodes ();
2287
2268
* errtype = TYPEMEM ;
2288
2269
return apr_psprintf (r -> pool , MCONTUI , node -> mess .JVMRoute );
2289
2270
}
2290
2271
2291
- if (insert_update_hosts (r -> server , hoststatsmem , vhost -> host , node -> mess .id , host -> vhost ) != APR_SUCCESS ) {
2272
+ if (insert_update_hosts (r -> server , hoststatsmem , aliases , node -> mess .id , host -> vhost ) != APR_SUCCESS ) {
2292
2273
loc_unlock_nodes ();
2293
2274
* errtype = TYPEMEM ;
2294
2275
return apr_psprintf (r -> pool , MHOSTUI , node -> mess .JVMRoute );
@@ -2324,11 +2305,11 @@ static char *process_appl_cmd(request_rec *r, char **ptr, int status, int *errty
2324
2305
}
2325
2306
}
2326
2307
} else if (status == STOPPED ) {
2327
- /* insert_update_contexts in fact makes that vhost->context corresponds only to the first context... */
2308
+ /* insert_update_contexts in fact makes that contexts corresponds only to the first context... */
2328
2309
contextinfo_t in ;
2329
2310
contextinfo_t * ou ;
2330
2311
in .id = 0 ;
2331
- strncpy (in .context , vhost -> context , CONTEXTSZ );
2312
+ strncpy (in .context , contexts , CONTEXTSZ );
2332
2313
in .context [CONTEXTSZ ] = '\0' ;
2333
2314
in .vhost = host -> vhost ;
2334
2315
in .node = node -> mess .id ;
@@ -2339,8 +2320,8 @@ static char *process_appl_cmd(request_rec *r, char **ptr, int status, int *errty
2339
2320
if (fromnode ) {
2340
2321
ap_set_content_type (r , PLAINTEXT_CONTENT_TYPE );
2341
2322
ap_rprintf (r , "Type=STOP-APP-RSP&JvmRoute=%.*s&Alias=%.*s&Context=%.*s&Requests=%d" ,
2342
- (int )sizeof (nodeinfo .mess .JVMRoute ), nodeinfo .mess .JVMRoute , (int )sizeof (vhost -> host ),
2343
- vhost -> host , (int )sizeof (vhost -> context ), vhost -> context , ou -> nbrequests );
2323
+ (int )sizeof (nodeinfo .mess .JVMRoute ), nodeinfo .mess .JVMRoute , (int )sizeof (aliases ),
2324
+ aliases , (int )sizeof (contexts ), contexts , ou -> nbrequests );
2344
2325
ap_rprintf (r , "\n" );
2345
2326
}
2346
2327
} else {
0 commit comments