Author: jfrederic.clere(a)jboss.com
Date: 2008-05-26 14:20:04 -0400 (Mon, 26 May 2008)
New Revision: 1620
Modified:
trunk/mod_cluster/native/mod_manager/mod_manager.c
Log:
Arrange *-APP Context/Alias.
Arrange REMOVE-APP.
Modified: trunk/mod_cluster/native/mod_manager/mod_manager.c
===================================================================
--- trunk/mod_cluster/native/mod_manager/mod_manager.c 2008-05-26 16:22:33 UTC (rev 1619)
+++ trunk/mod_cluster/native/mod_manager/mod_manager.c 2008-05-26 18:20:04 UTC (rev 1620)
@@ -64,6 +64,8 @@
#define SCONBAD "SYNTAX: Context without Alias"
#define SBADFLD "SYNTAX: Invalid field \"%s\" in message"
#define SCMDUNS "SYNTAX: Command is not supported"
+#define SMULALB "SYNTAX: Only one Alias in APP command"
+#define SMULCTB "SYNTAX: Only one Context in APP command"
#define TYPEMEM 2
#define MNODEUI "MEM: Can't update or insert node"
@@ -336,6 +338,7 @@
while (*ptr) {
if (*ptr == ',') {
*ptr = '\0';
+ info.id = 0;
strncpy(info.context, previous, sizeof(info.context));
if (status != REMOVE)
insert_update_context(mem, &info);
@@ -348,6 +351,7 @@
}
ptr ++;
}
+ info.id = 0;
strncpy(info.context, previous, sizeof(info.context));
if (status != REMOVE)
insert_update_context(mem, &info);
@@ -506,6 +510,8 @@
/* Insert the Alias and corresponding Context */
phost = vhost;
+ if (phost->host == NULL && phost->context == NULL)
+ return NULL; /* Alias and Context missing */
int vid = 1; /* zero and "" is empty */
while (phost) {
insert_update_hosts(hoststatsmem, phost->host, id, vid);
@@ -566,7 +572,6 @@
nodeinfo_t nodeinfo;
nodeinfo_t *node;
struct cluster_host *vhost;
- struct cluster_host *phost;
char **ptr = process_buff(r, buff);
if (ptr == NULL) {
@@ -575,11 +580,10 @@
}
/* Map nothing by default */
+ vhost = apr_palloc(r->pool, sizeof(struct cluster_host));
vhost->host = NULL;
vhost->context = NULL;
vhost->next = NULL;
- vhost = apr_palloc(r->pool, sizeof(struct cluster_host));
- phost = vhost;
int i = 0;
while (ptr[i]) {
@@ -592,26 +596,18 @@
nodeinfo.mess.id = 0;
}
if (strcasecmp(ptr[i], "Alias") == 0) {
- if (phost->host && !phost->context) {
+ if (vhost->host) {
*errtype = TYPESYNTAX;
- return SALIBAD;
+ return SMULALB;
}
- if (phost->host) {
- phost->next = apr_palloc(r->pool, sizeof(struct cluster_host));
- phost = phost->next;
- phost->next = NULL;
- phost->host = ptr[i+1];
- phost->context = NULL;
- } else {
- phost->host = ptr[i+1];
- }
+ vhost->host = ptr[i+1];
}
if (strcasecmp(ptr[i], "Context") == 0) {
- if (phost->context) {
+ if (vhost->context) {
*errtype = TYPESYNTAX;
- return SCONBAD;
+ return SMULCTB;
}
- phost->context = ptr[i+1];
+ vhost->context = ptr[i+1];
}
i++;
i++;
@@ -642,7 +638,7 @@
return NULL;
/* If the Host doesn't exist yet create it */
int vid = 1; /* XXX: That is not really the right value, but that works most time
*/
- insert_update_hosts(hoststatsmem, phost->host, node->mess.id, vid);
+ insert_update_hosts(hoststatsmem, vhost->host, node->mess.id, vid);
hostinfo.id = 0;
if (vhost->host != NULL)
strcpy(hostinfo.host, vhost->host);
@@ -656,7 +652,25 @@
}
/* Now update each context from Context: part */
- insert_update_contexts(contextstatsmem, phost->context, node->mess.id,
host->vhost, status);
+ insert_update_contexts(contextstatsmem, vhost->context, node->mess.id,
host->vhost, status);
+
+ /* Remove the host if all the contextes have been removed */
+ if (status == REMOVE) {
+ int size = get_max_size_context(contextstatsmem);
+ int *id = apr_palloc(r->pool, sizeof(int) * size);
+ size = get_ids_used_context(contextstatsmem, id);
+ for (i=0; i<size; i++) {
+ contextinfo_t *ou;
+ get_context(contextstatsmem, &ou, id[i]);
+ if (ou->vhost == host->vhost &&
+ ou->node == node->mess.id)
+ break;
+ }
+ if (i==size) {
+ hostinfo.id = host->vhost;
+ remove_host(hoststatsmem, &hostinfo);
+ }
+ }
return NULL;
}
static char * process_enable(request_rec *r, char *buff, int *errtype)