You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by jf...@apache.org on 2009/09/30 10:50:57 UTC
svn commit: r820213 - in /httpd/httpd/trunk/modules:
cluster/mod_heartmonitor.c proxy/balancers/mod_lbmethod_heartbeat.c
proxy/mod_serf.c
Author: jfclere
Date: Wed Sep 30 08:50:57 2009
New Revision: 820213
URL: http://svn.apache.org/viewvc?rev=820213&view=rev
Log:
Add port in the logic.
Modified:
httpd/httpd/trunk/modules/cluster/mod_heartmonitor.c
httpd/httpd/trunk/modules/proxy/balancers/mod_lbmethod_heartbeat.c
httpd/httpd/trunk/modules/proxy/mod_serf.c
Modified: httpd/httpd/trunk/modules/cluster/mod_heartmonitor.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/cluster/mod_heartmonitor.c?rev=820213&r1=820212&r2=820213&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/cluster/mod_heartmonitor.c (original)
+++ httpd/httpd/trunk/modules/cluster/mod_heartmonitor.c Wed Sep 30 08:50:57 2009
@@ -48,6 +48,7 @@
const char *ip;
int busy;
int ready;
+ unsigned int port;
apr_time_t seen;
} hm_server_t;
@@ -321,13 +322,19 @@
node.seen = SEEN_TIMEOUT;
}
seen = fage + node.seen;
- apr_file_printf(fp, "%s &ready=%u&busy=%u&lastseen=%u\n",
- ip, node.ready, node.busy, (unsigned int) seen);
+
+ if (apr_table_get(hbt, "port")) {
+ node.port = atoi(apr_table_get(hbt, "port"));
+ } else {
+ node.port = 80;
+ }
+ apr_file_printf(fp, "%s &ready=%u&busy=%u&lastseen=%u&port=%u\n",
+ ip, node.ready, node.busy, (unsigned int) seen, node.port);
} else {
apr_time_t seen;
seen = apr_time_sec(now - s->seen);
- apr_file_printf(fp, "%s &ready=%u&busy=%u&lastseen=%u\n",
- s->ip, s->ready, s->busy, (unsigned int) seen);
+ apr_file_printf(fp, "%s &ready=%u&busy=%u&lastseen=%u&port=%u\n",
+ s->ip, s->ready, s->busy, (unsigned int) seen, s->port);
updated = 1;
}
} while (1);
@@ -336,8 +343,8 @@
if (!updated) {
apr_time_t seen;
seen = apr_time_sec(now - s->seen);
- apr_file_printf(fp, "%s &ready=%u&busy=%u&lastseen=%u\n",
- s->ip, s->ready, s->busy, (unsigned int) seen);
+ apr_file_printf(fp, "%s &ready=%u&busy=%u&lastseen=%u&port=%u\n",
+ s->ip, s->ready, s->busy, (unsigned int) seen, s->port);
}
rv = apr_file_flush(fp);
@@ -414,8 +421,8 @@
*/
}
else {
- apr_file_printf(fp, "%s &ready=%u&busy=%u&lastseen=%u\n",
- s->ip, s->ready, s->busy, (unsigned int) seen);
+ apr_file_printf(fp, "%s &ready=%u&busy=%u&lastseen=%u&port=%u\n",
+ s->ip, s->ready, s->busy, (unsigned int) seen, s->port);
}
}
@@ -488,7 +495,7 @@
return hm_file_update_stats(ctx, p);
}
-static hm_server_t *hm_get_server(hm_ctx_t *ctx, const char *ip)
+static hm_server_t *hm_get_server(hm_ctx_t *ctx, const char *ip, const int port)
{
hm_server_t *s;
@@ -497,6 +504,7 @@
if (s == NULL) {
s = apr_palloc(ctx->p, sizeof(hm_server_t));
s->ip = apr_pstrdup(ctx->p, ip);
+ s->port = port;
s->ready = 0;
s->busy = 0;
s->seen = 0;
@@ -506,7 +514,7 @@
return s;
}
-/* Process a message receive from a backend node */
+/* Process a message received from a backend node */
static void hm_processmsg(hm_ctx_t *ctx, apr_pool_t *p,
apr_sockaddr_t *from, char *buf, int len)
{
@@ -522,6 +530,7 @@
apr_table_get(tbl, "busy") != NULL &&
apr_table_get(tbl, "ready") != NULL) {
char *ip;
+ int port = 80;
hm_server_t *s;
/* TODO: REMOVE ME BEFORE PRODUCTION (????) */
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, ctx->s,
@@ -530,7 +539,10 @@
apr_sockaddr_ip_get(&ip, from);
- s = hm_get_server(ctx, ip);
+ if (apr_table_get(tbl, "port") != NULL)
+ port = atoi(apr_table_get(tbl, "port"));
+
+ s = hm_get_server(ctx, ip, port);
s->busy = atoi(apr_table_get(tbl, "busy"));
s->ready = atoi(apr_table_get(tbl, "ready"));
@@ -739,6 +751,9 @@
qs_to_table(buf, tbl, r->pool);
apr_sockaddr_ip_get(&ip, r->connection->remote_addr);
hmserver.ip = ip;
+ hmserver.port = 80;
+ if (apr_table_get(tbl, "port") != NULL)
+ hmserver.port = atoi(apr_table_get(tbl, "port"));
hmserver.busy = atoi(apr_table_get(tbl, "busy"));
hmserver.ready = atoi(apr_table_get(tbl, "ready"));
hmserver.seen = apr_time_now();
Modified: httpd/httpd/trunk/modules/proxy/balancers/mod_lbmethod_heartbeat.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/balancers/mod_lbmethod_heartbeat.c?rev=820213&r1=820212&r2=820213&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/balancers/mod_lbmethod_heartbeat.c (original)
+++ httpd/httpd/trunk/modules/proxy/balancers/mod_lbmethod_heartbeat.c Wed Sep 30 08:50:57 2009
@@ -48,6 +48,7 @@
int busy;
int ready;
int seen;
+ int port;
int id;
proxy_worker *worker;
} hb_server_t;
@@ -161,6 +162,7 @@
if (server == NULL) {
server = apr_pcalloc(pool, sizeof(hb_server_t));
server->ip = ip;
+ server->port = 80;
server->seen = -1;
apr_hash_set(servers, server->ip, APR_HASH_KEY_STRING, server);
@@ -182,6 +184,10 @@
server->seen = atoi(apr_table_get(hbt, "lastseen"));
}
+ if (apr_table_get(hbt, "port")) {
+ server->port = atoi(apr_table_get(hbt, "port"));
+ }
+
if (server->busy == 0 && server->ready != 0) {
/* Server has zero threads active, but lots of them ready,
* it likely just started up, so lets /4 the number ready,
Modified: httpd/httpd/trunk/modules/proxy/mod_serf.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/mod_serf.c?rev=820213&r1=820212&r2=820213&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_serf.c (original)
+++ httpd/httpd/trunk/modules/proxy/mod_serf.c Wed Sep 30 08:50:57 2009
@@ -835,6 +835,7 @@
int busy;
int ready;
int seen;
+ unsigned int port;
} hb_server_t;
static void
@@ -913,6 +914,7 @@
t++;
server = apr_pcalloc(pool, sizeof(hb_server_t));
server->ip = ip;
+ server->port = 80;
server->seen = -1;
apr_table_clear(hbt);
@@ -930,6 +932,10 @@
server->seen = atoi(apr_table_get(hbt, "lastseen"));
}
+ if (apr_table_get(hbt, "port")) {
+ server->port = atoi(apr_table_get(hbt, "port"));
+ }
+
if (server->busy == 0 && server->ready != 0) {
/* Server has zero threads active, but lots of them ready,
* it likely just started up, so lets /4 the number ready,
@@ -1002,8 +1008,7 @@
if (hbs->ready > 0) {
x = apr_palloc(r->pool, sizeof(ap_serf_server_t));
x->ip = apr_pstrdup(r->pool, hbs->ip);
- /* TODO: expand multicast format to support ports? */
- x->port = 80;
+ x->port = hbs->port;
APR_ARRAY_PUSH(servers, ap_serf_server_t *) = x;
}
}