const char *ip;
int busy;
int ready;
+ unsigned int port;
apr_time_t seen;
} hm_server_t;
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);
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);
*/
}
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);
}
}
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;
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;
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)
{
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,
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"));
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();
int busy;
int ready;
int seen;
+ unsigned int port;
} hb_server_t;
static void
t++;
server = apr_pcalloc(pool, sizeof(hb_server_t));
server->ip = ip;
+ server->port = 80;
server->seen = -1;
apr_table_clear(hbt);
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,
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;
}
}