JBoss Native SVN: r1732 - trunk/mod_cluster/native/mod_manager.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2008-06-26 11:24:05 -0400 (Thu, 26 Jun 2008)
New Revision: 1732
Modified:
trunk/mod_cluster/native/mod_manager/mod_manager.c
Log:
Add the JVMRoute.
Modified: trunk/mod_cluster/native/mod_manager/mod_manager.c
===================================================================
--- trunk/mod_cluster/native/mod_manager/mod_manager.c 2008-06-26 15:04:18 UTC (rev 1731)
+++ trunk/mod_cluster/native/mod_manager/mod_manager.c 2008-06-26 15:24:05 UTC (rev 1732)
@@ -733,8 +733,9 @@
id[i], ou->mess.id, ou->mess.JVMRoute, ou->mess.Domain,
ou->mess.Host, ou->mess.Port, ou->mess.Type);
proxystat = (proxy_worker_stat *) ou->stat;
- ap_rprintf(r, " [%d:%d] status: %d elected: %d lbstatus: %d lbfactor: %d\n",
- id[i], ou->mess.id, proxystat->status, proxystat->elected, proxystat->lbstatus, proxystat->lbfactor);
+ ap_rprintf(r, " [%d:%d] status: %d elected: %d lbstatus: %d lbfactor: %d route: %s\n",
+ id[i], ou->mess.id, proxystat->status, proxystat->elected, proxystat->lbstatus,
+ proxystat->lbfactor, proxystat->route);
}
return NULL;
16 years, 6 months
JBoss Native SVN: r1731 - trunk/mod_cluster/native/mod_proxy_cluster.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2008-06-26 11:04:18 -0400 (Thu, 26 Jun 2008)
New Revision: 1731
Modified:
trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c
Log:
Add the logic to "remove" the worker from the apr_array of the balancer.
Modified: trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c
===================================================================
--- trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c 2008-06-26 08:47:20 UTC (rev 1730)
+++ trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c 2008-06-26 15:04:18 UTC (rev 1731)
@@ -70,9 +70,9 @@
*/
static void create_worker(proxy_server_conf *conf, proxy_balancer *balancer,
server_rec *server, proxy_worker **worker,
- nodeinfo_t *node)
+ nodeinfo_t *node, apr_pool_t *pool)
{
- char url[SCHEMENDSZ+HOSTNODESZ+PORTNODESZ+5]; /* Type :// Host : Port */
+ char *url;
char *ptr;
int reuse = 0;
#if AP_MODULE_MAGIC_AT_LEAST(20051115,4)
@@ -81,11 +81,7 @@
#endif
/* build the name (scheme and port) when needed */
- strcpy(url, node->mess.Type);
- strcat(url, "://");
- strcat(url, node->mess.Host);
- strcat(url, ":");
- strcat(url, node->mess.Port);
+ url = apr_pstrcat(pool, node->mess.Type, "://", node->mess.Host, ":", node->mess.Port, NULL);
*worker = ap_proxy_get_worker(conf->pool, conf, url);
if ((*worker) == NULL) {
@@ -162,7 +158,8 @@
/* XXX: We need that information from TC */
(*worker)->s->redirect[0] = '\0';
}
- (*worker)->s->lbstatus = -1; /* prevent using the node using status message */
+ (*worker)->s->lbstatus = 0;
+ (*worker)->s->lbfactor = -1; /* prevent using the node using status message */
if (!reuse) {
/*
@@ -176,14 +173,11 @@
/* Update the corresponding balancer worker information */
proxy_worker *runtime;
int i;
- char name[HOSTNODESZ+PORTNODESZ+2];
+
runtime = (proxy_worker *)balancer->workers->elts;
- strcpy(name, node->mess.Host);
- strcat(name, ":");
- strcat(name, node->mess.Port);
for (i = 0; i < balancer->workers->nelts; i++, runtime++) {
if (runtime->name) {
- if (strcmp(name, runtime->name) == 0) {
+ if (strcmp(url, runtime->name) == 0) {
memcpy(runtime, (*worker), sizeof(proxy_worker));
}
}
@@ -244,7 +238,7 @@
}
}
if (balancer) {
- create_worker(conf, balancer, server, &worker, node);
+ create_worker(conf, balancer, server, &worker, node, pool);
} else {
ap_log_error(APLOG_MARK, APLOG_NOTICE|APLOG_NOERRNO, 0, server,
"add_workers_node: Can't find balancer");
@@ -287,15 +281,32 @@
"remove_workers_node %d", i);
if (i == 0) {
/* No connection in use: clean the worker */
+ proxy_balancer *balancer;
+ char *name = apr_pstrcat(pool, "cluster://", node->mess.balancer, NULL);
+
+ /* mark the worker removed in the apr_array of the balancer */
+ balancer = (proxy_balancer *)conf->balancers->elts;
+ for (i = 0; i < conf->balancers->nelts; i++, balancer++) {
+ if (strcmp(balancer->name, name) == 0) {
+ int j;
+ proxy_worker *searched = (proxy_worker *)balancer->workers->elts;
+ for (j = 0; j < balancer->workers->nelts; j++, searched++) {
+ if (searched->id == worker->id) {
+ searched->id = 0; /* mark it removed */
+ }
+ }
+ }
+ }
+
+ /* Clear the connection pool (close the sockets) */
if (worker->cp->pool) {
apr_pool_destroy(worker->cp->pool);
worker->cp->pool = NULL;
}
- worker->id = 0;
/* XXX: Shouldnn't we remove the mutex too (worker->mutex) */
- /* XXX: How to remove the worker from the apr_array of the balancer */
+ worker->id = 0; /* mark it removed */
return (0);
} else
@@ -606,7 +617,7 @@
int i;
balancer = (proxy_balancer *)conf->balancers->elts;
- for (i = 0; i < conf->balancers->nelts; i++) {
+ for (i = 0; i < conf->balancers->nelts; i++, balancer++) {
if (strcasecmp(balancer->name, uri) == 0)
break;
}
@@ -744,6 +755,8 @@
while (!mycandidate && !checked_standby) {
worker = (proxy_worker *)balancer->workers->elts;
for (i = 0; i < balancer->workers->nelts; i++, worker++) {
+ if (worker->id == 0)
+ continue; /* marked removed */
/* standby logic
* lbfactor: -1 broken node.
16 years, 6 months
JBoss Native SVN: r1730 - trunk/mod_cluster/native/mod_proxy_cluster.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2008-06-26 04:47:20 -0400 (Thu, 26 Jun 2008)
New Revision: 1730
Modified:
trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c
Log:
Only lock if we have to update something.
Modified: trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c
===================================================================
--- trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c 2008-06-26 08:13:49 UTC (rev 1729)
+++ trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c 2008-06-26 08:47:20 UTC (rev 1730)
@@ -310,16 +310,14 @@
apr_time_t last;
int notok = 0;
- apr_thread_mutex_lock(lock);
-
/* Check if we have to do something */
last = node_storage->worker_nodes_need_update(server, pool);
/* nodes_need_update will return 1 if last_updated is zero: first time we are called */
if (last == 0) {
- apr_thread_mutex_unlock(lock);
return;
}
+ apr_thread_mutex_lock(lock);
/* read the ident of the nodes */
id = apr_pcalloc(pool, sizeof(int) * node_storage->get_max_size_node());
16 years, 6 months
JBoss Native SVN: r1729 - trunk/mod_cluster/native/mod_proxy_cluster.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2008-06-26 04:13:49 -0400 (Thu, 26 Jun 2008)
New Revision: 1729
Modified:
trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c
Log:
Prevent using the node before the first (ok) status message.
Use a #define for the time before removing a node.
Modified: trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c
===================================================================
--- trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c 2008-06-25 15:34:04 UTC (rev 1728)
+++ trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c 2008-06-26 08:13:49 UTC (rev 1729)
@@ -63,6 +63,8 @@
static apr_thread_mutex_t *lock = NULL;
+#define WAITFORREMOVE 10 /* seconds */
+
/*
* Create/Get the worker before using it
*/
@@ -160,7 +162,7 @@
/* XXX: We need that information from TC */
(*worker)->s->redirect[0] = '\0';
}
- (*worker)->s->lbstatus = 1;
+ (*worker)->s->lbstatus = -1; /* prevent using the node using status message */
if (!reuse) {
/*
@@ -1069,7 +1071,7 @@
for (i=0; i<size; i++) {
nodeinfo_t *ou;
node_storage->read_node(id[i], &ou);
- if (ou->mess.remove && (now - ou->updatetime) >= apr_time_from_sec(10)) {
+ if (ou->mess.remove && (now - ou->updatetime) >= apr_time_from_sec(WAITFORREMOVE)) {
/* remove the node from the shared memory */
node_storage->remove_node(ou);
}
16 years, 6 months
JBoss Native SVN: r1728 - trunk/mod_cluster/native/mod_proxy_cluster.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2008-06-25 11:34:04 -0400 (Wed, 25 Jun 2008)
New Revision: 1728
Modified:
trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c
Log:
(Re)create the connection pool when reusing the worker.
Modified: trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c
===================================================================
--- trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c 2008-06-25 10:13:25 UTC (rev 1727)
+++ trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c 2008-06-25 15:34:04 UTC (rev 1728)
@@ -105,6 +105,16 @@
/* We are going to reuse a removed one */
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, server,
"Created: reusing worker for %s", url);
+ if ((*worker)->cp->pool == NULL) {
+ /* Copied for init_conn_pool in modules/proxy/proxy_util.c */
+ apr_pool_t *pool;
+ proxy_conn_pool *cp;
+ apr_pool_create(&pool, conf->pool);
+ apr_pool_tag(pool, "proxy_worker_cp");
+ cp = (proxy_conn_pool *)apr_pcalloc(conf->pool, sizeof(proxy_conn_pool));
+ cp->pool = pool;
+ (*worker)->cp = cp;
+ }
reuse = 1;
} else {
return; /* Done Already existing */
@@ -281,6 +291,8 @@
}
worker->id = 0;
+ /* XXX: Shouldnn't we remove the mutex too (worker->mutex) */
+
/* XXX: How to remove the worker from the apr_array of the balancer */
return (0);
16 years, 6 months
JBoss Native SVN: r1727 - trunk/build/unix.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2008-06-25 06:13:25 -0400 (Wed, 25 Jun 2008)
New Revision: 1727
Modified:
trunk/build/unix/package.list
Log:
Use the tagged TC-native.
Modified: trunk/build/unix/package.list
===================================================================
--- trunk/build/unix/package.list 2008-06-24 09:37:41 UTC (rev 1726)
+++ trunk/build/unix/package.list 2008-06-25 10:13:25 UTC (rev 1727)
@@ -4,7 +4,7 @@
jboss-native|2.0.2|TOMCAT_NATIVE_1_1_11|apr:v:1.2.9|apu:v:1.2.8|api:v:1.2.1|ssl:v:0.9.8e|zlib:v:1.2.3
jboss-native|2.0.3|TOMCAT_NATIVE_1_1_12|apr:v:1.2.8|apu:v:1.2.8|api:v:1.2.1|ssl:v:0.9.8e|zlib:v:1.2.3
jboss-native|2.0.4|TOMCAT_NATIVE_1_1_13|apr:v:1.2.8|apu:v:1.2.8|api:v:1.2.1|ssl:v:0.9.8e|zlib:v:1.2.3
-jboss-native|2.0.5-dev|trunk|apr:v:1.2.12|apu:v:1.2.12|api:v:1.2.1|ssl:v:0.9.8e|zlib:v:1.2.3
+jboss-native|2.0.5-dev|TOMCAT_NATIVE_1_1_14|apr:v:1.2.8|apu:v:1.2.8|api:v:1.2.1|ssl:v:0.9.8e|zlib:v:1.2.3
# SIGHT
jboss-sight|1.0.0|trunk|apr:v:1.2.9|apu:v:1.2.8|api:v:1.2.1
jboss-sight|1.0.1|trunk|apr:v:1.2.8|apu:v:1.2.8|api:v:1.2.1
16 years, 6 months
JBoss Native SVN: r1726 - trunk/mod_cluster/native/mod_proxy_cluster.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2008-06-24 05:37:41 -0400 (Tue, 24 Jun 2008)
New Revision: 1726
Modified:
trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c
Log:
The apr_time_from_sec() is already called in mod_manager.c
Modified: trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c
===================================================================
--- trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c 2008-06-24 09:32:17 UTC (rev 1725)
+++ trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c 2008-06-24 09:37:41 UTC (rev 1726)
@@ -223,7 +223,7 @@
balancer->sticky = apr_psprintf(conf->pool, "%s|%s", balan->StickySessionCookie,
balan->StickySessionPath);
balancer->sticky_force = balan->StickySessionForce;
- balancer->timeout = apr_time_from_sec(balan->Timeout);
+ balancer->timeout = balan->Timeout;
balancer->max_attempts = balan->Maxattempts;
balancer->max_attempts_set = 1;
16 years, 6 months
JBoss Native SVN: r1725 - trunk/mod_cluster/native/mod_proxy_cluster.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2008-06-24 05:32:17 -0400 (Tue, 24 Jun 2008)
New Revision: 1725
Modified:
trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c
Log:
Arrange small problems...
Modified: trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c
===================================================================
--- trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c 2008-06-20 07:48:51 UTC (rev 1724)
+++ trunk/mod_cluster/native/mod_proxy_cluster/mod_proxy_cluster.c 2008-06-24 09:32:17 UTC (rev 1725)
@@ -183,6 +183,7 @@
/*
* Add a node to the worker conf
+ * NOTE: pool is the request pool or any temporary pool. Use conf->pool for any data that live longer.
*/
static void add_workers_node(nodeinfo_t *node, proxy_server_conf *conf, apr_pool_t *pool, server_rec *server)
{
@@ -219,7 +220,7 @@
/* Something like cluster://cluster1 and cluster1 */
if (strcmp(balan->balancer, &balancer->name[10]) == 0) {
/* XXX: StickySession, StickySessionRemove not in */
- balancer->sticky = apr_psprintf(pool, "%s|%s", balan->StickySessionCookie,
+ balancer->sticky = apr_psprintf(conf->pool, "%s|%s", balan->StickySessionCookie,
balan->StickySessionPath);
balancer->sticky_force = balan->StickySessionForce;
balancer->timeout = apr_time_from_sec(balan->Timeout);
@@ -866,6 +867,7 @@
#endif
{
/* create the new connection if the previous was destroyed */
+ rv = APR_SUCCESS;
if (!worker->cp->conn) {
/* XXX: What appends is worker->cp->pool is NULL */
if (worker->cp->pool)
@@ -877,7 +879,6 @@
conn = worker->cp->conn;
worker->cp->conn = NULL;
}
- rv = APR_SUCCESS;
}
if (rv != APR_SUCCESS) {
@@ -1393,13 +1394,18 @@
* If balancer is already provided skip the search
* for balancer, because this is failover attempt.
*/
+ apr_thread_mutex_lock(lock);
if (!*balancer &&
- !(*balancer = ap_proxy_get_balancer(r->pool, conf, *url)))
+ !(*balancer = ap_proxy_get_balancer(r->pool, conf, *url))) {
+ apr_thread_mutex_unlock(lock);
return DECLINED;
+ }
/* Step 2: find the session route */
runtime = find_session_route(*balancer, r, &route, &sticky, url);
+ apr_thread_mutex_unlock(lock);
+
/* Lock the LoadBalancer
* XXX: perhaps we need the process lock here
*/
16 years, 6 months
JBoss Native SVN: r1724 - sandbox/httpd.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2008-06-20 03:48:51 -0400 (Fri, 20 Jun 2008)
New Revision: 1724
Modified:
sandbox/httpd/httpd.test
Log:
Stop httpd even if the tests failed.
Modified: sandbox/httpd/httpd.test
===================================================================
--- sandbox/httpd/httpd.test 2008-06-19 08:58:46 UTC (rev 1723)
+++ sandbox/httpd/httpd.test 2008-06-20 07:48:51 UTC (rev 1724)
@@ -225,13 +225,14 @@
echo "Start FAILED"
exit 1
fi
+rc=0
curl -v http://localhost:7779 | grep "It works\!"
if [ $? -ne 0 ]; then
echo "Test FAILED"
- exit 1
+ rc=1
fi
(cd $HOME/$TMPLOC/APACHE
bin/apachectl stop
)
echo "DONE"
-exit 0
+exit $rc
16 years, 6 months
JBoss Native SVN: r1723 - trunk/mod_cluster/native/mod_slotmem.
by jbossnative-commits@lists.jboss.org
Author: mladen.turk(a)jboss.com
Date: 2008-06-19 04:58:46 -0400 (Thu, 19 Jun 2008)
New Revision: 1723
Modified:
trunk/mod_cluster/native/mod_slotmem/sharedmem_util.c
Log:
Add sharedmem unixd util
Modified: trunk/mod_cluster/native/mod_slotmem/sharedmem_util.c
===================================================================
--- trunk/mod_cluster/native/mod_slotmem/sharedmem_util.c 2008-06-18 16:00:03 UTC (rev 1722)
+++ trunk/mod_cluster/native/mod_slotmem/sharedmem_util.c 2008-06-19 08:58:46 UTC (rev 1723)
@@ -37,6 +37,25 @@
#include "slotmem.h"
+#include "httpd.h"
+#ifdef AP_NEED_SET_MUTEX_PERMS
+#include "unixd.h"
+#endif
+
+#if APR_HAVE_UNISTD_H
+#include <unistd.h> /* for getpid() */
+#endif
+
+#if HAVE_SYS_SEM_H
+#include <sys/shm.h>
+#if !defined(SHM_R)
+#define SHM_R 0400
+#endif
+#if !defined(SHM_W)
+#define SHM_W 0200
+#endif
+#endif
+
/* The description of the slots to reuse the slotmem */
struct sharedslotdesc {
apr_size_t item_size;
@@ -59,6 +78,36 @@
static struct ap_slotmem *globallistmem = NULL;
static apr_pool_t *globalpool = NULL;
+apr_status_t unixd_set_shm_perms(const char *fname)
+{
+#ifdef AP_NEED_SET_MUTEX_PERMS
+#if APR_USE_SHMEM_SHMGET || APR_USE_SHMEM_SHMGET_ANON
+ struct shmid_ds shmbuf;
+ key_t shmkey;
+ int shmid;
+
+ shmkey = ftok(fname, 1);
+ if (shmkey == (key_t)-1) {
+ return errno;
+ }
+ if ((shmid = shmget(shmkey, 0, SHM_R | SHM_W)) == -1) {
+ return errno;
+ }
+ shmbuf.shm_perm.uid = unixd_config.user_id;
+ shmbuf.shm_perm.gid = unixd_config.group_id;
+ shmbuf.shm_perm.mode = 0600;
+ if (shmctl(shmid, IPC_SET, &shmbuf) == -1) {
+ return errno;
+ }
+ return APR_SUCCESS;
+#else
+ return APR_ENOTIMPL;
+#endif
+#else
+ return APR_ENOTIMPL;
+#endif
+}
+
/*
* Persiste the slotmem in a file
* slotmem name and file name.
@@ -237,7 +286,13 @@
if (rv != APR_SUCCESS) {
return rv;
}
-
+ if (name) {
+ /* Set permissions to shared memory
+ * so it can be attached by child process
+ * having different user credentials
+ */
+ unixd_set_shm_perms(fname);
+ }
ptr = apr_shm_baseaddr_get(res->shm);
desc.item_size = item_size;
desc.item_num = item_num;
16 years, 6 months