Author: jfrederic.clere(a)jboss.com
Date: 2008-06-16 05:04:05 -0400 (Mon, 16 Jun 2008)
New Revision: 1699
Modified:
trunk/mod_cluster/native/advertise/mod_advertise.c
Log:
Allow it in ONE VirtualHost.
Try to guess the X-Manager-Address and X-Manager-Protocol from the Server configuration.
Modified: trunk/mod_cluster/native/advertise/mod_advertise.c
===================================================================
--- trunk/mod_cluster/native/advertise/mod_advertise.c 2008-06-16 07:39:46 UTC (rev 1698)
+++ trunk/mod_cluster/native/advertise/mod_advertise.c 2008-06-16 09:04:05 UTC (rev 1699)
@@ -133,10 +133,9 @@
static const char *cmd_advertise_m(cmd_parms *cmd, void *dummy,
const char *arg, const char *opt)
{
- const char *errs = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (errs != NULL)
- return errs;
+ if (ma_advertise_adrs)
+ return "Duplicate ServerAdvertise directives are not allowed";
if (strcasecmp(arg, "Off") == 0)
ma_advertise_mode = ma_advertise_off;
@@ -158,6 +157,7 @@
!ma_advertise_srvp)
return "Invalid ServerAdvertise Address";
}
+ ma_server_rec = cmd->server; /* Virtual Host containing the directive */
return NULL;
}
@@ -170,12 +170,8 @@
static const char *cmd_advertise_g(cmd_parms *cmd, void *dummy,
const char *arg)
{
- const char *errs = ap_check_cmd_context(cmd, GLOBAL_ONLY);
-
- if (errs != NULL)
- return errs;
if (ma_advertise_set)
- return "Duplicate AdvertiseGroup directives are not allowed";
+ return "Duplicate AdvertiseGroup directives are not allowed";
if (apr_parse_addr_port(&ma_advertise_adrs,
&ma_advertise_adsi,
@@ -200,10 +196,9 @@
{
apr_time_t s, u = 0;
const char *p;
- const char *errs = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (errs != NULL)
- return errs;
+ if (ma_advertise_freq != MA_DEFAULT_ADV_FREQ)
+ return "Duplicate AdvertiseFrequency directives are not allowed";
if ((p = ap_strchr_c(arg, '.')) || (p = ap_strchr_c(arg, ',')))
u = atoi(p + 1);
@@ -489,7 +484,6 @@
}
}
#endif
- ma_server_rec = s;
if (!magd->generation) {
/* Favor dynamic configuration */
if (ma_advertise_skey) {
@@ -504,9 +498,6 @@
}
if (!ma_advertise_srvh)
ma_advertise_srvh = magd->srvid;
- if (!ma_advertise_srvm)
- ma_advertise_srvm = apr_pstrdup(pconf, "http");
-
/* Check if we have advertise set */
if (ma_advertise_mode != ma_advertise_off &&
ma_advertise_set && ma_advertise_adrs) {
@@ -523,6 +514,44 @@
}
}
+ /* Fill default values */
+ if (!ma_advertise_srvm) {
+ if (ma_server_rec && ma_server_rec->server_scheme) {
+ /* ServerName scheme://fully-qualified-domain-name[:port] */
+ ma_advertise_srvm = apr_pstrdup(pconf, ma_server_rec->server_scheme);
+ } else {
+ ma_advertise_srvm = apr_pstrdup(pconf, "http");
+ }
+ }
+
+ if (ma_advertise_srvs == NULL && ma_server_rec) {
+ /*
+ * That is not easy just use ServerAdvertise with the server parameter
+ * if the code below doesn't work
+ */
+ char *ptr;
+ int port = DEFAULT_HTTP_PORT;
+ if (ma_server_rec->addrs && ma_server_rec->addrs->host_addr
&&
+ ma_server_rec->addrs->host_addr->next == NULL) {
+ ptr = apr_psprintf(pproc, "%pI",
ma_server_rec->addrs->host_addr);
+ } else {
+ if ( ma_server_rec->port !=0 || ma_server_rec->port !=1)
+ port = ma_server_rec->port;
+ ptr = apr_psprintf(pproc, "%s:%lu",
ma_server_rec->server_hostname, port);
+ }
+ rv = apr_parse_addr_port(&ma_advertise_srvs,
+ &ma_advertise_srvi,
+ &ma_advertise_srvp,
+ ptr, pproc);
+ if (rv != APR_SUCCESS || !ma_advertise_srvs ||
+ !ma_advertise_srvp) {
+ ap_log_error(APLOG_MARK, APLOG_CRIT, rv, s,
+ "mod_advertise: Invalid ServerAdvertise Address %s",
+ ptr);
+ return rv;
+ }
+ }
+
/* Create parent management thread */
is_mp_running = 1;
rv = apr_thread_create(&tp, NULL, parent_thread, s, pconf);