[svn:modperl-modules] rev 149 - in Apache-Scoreboard-2.0/trunk: . apxs
[email protected] 26 Feb 2005 17:20:55 -0000
| Newsgroups | perl.modperl.modules.svn |
|---|---|
| Message-ID | <[email protected]> |
Author: stas
Date: Sat Feb 26 09:20:55 2005
New Revision: 149
Modified:
Apache-Scoreboard-2.0/trunk/Scoreboard.xs
Apache-Scoreboard-2.0/trunk/apxs/send.c
Log:
when freezing/sending don't try to figure out what are the live servers,
since a sequential search doesn't work. if a server went away, there will
be a hole, e.g. if C goes down in ABCDE, we will get ABXDE and send only
AB info. so just send them all
- starting to drop the dup of server_limit/thread_limit data as it's
already located in global_score
Modified: Apache-Scoreboard-2.0/trunk/Scoreboard.xs
==============================================================================
--- Apache-Scoreboard-2.0/trunk/Scoreboard.xs (original)
+++ Apache-Scoreboard-2.0/trunk/Scoreboard.xs Sat Feb 26 09:20:55 2005
@@ -47,8 +47,8 @@
static char status_flags[SERVER_NUM_STATUS];
-#define server_limit(image) image->server_limit
-#define thread_limit(image) image->thread_limit
+#define server_limit(image) image->sb->global->server_limit
+#define thread_limit(image) image->sb->global->thread_limit
#define scoreboard_up_time(image) \
(apr_uint32_t) apr_time_sec( \
@@ -195,7 +195,7 @@
Apache::Scoreboard image
PREINIT:
- int server_num, psize, ssize, tsize;
+ int psize, ssize, tsize;
char buf[SIZE16*4];
char *dptr, *data, *ptr = buf;
scoreboard *sb;
@@ -203,20 +203,12 @@
CODE:
sb = image->sb;
- for (server_num = 0; server_num < image->server_limit; server_num++) {
- if (!sb->parent[server_num].pid) {
- break;
- }
- }
-
- //server_num = image->server_limit;
-
- psize = sizeof(process_score) * server_num;
- ssize = sizeof(worker_score) * server_num * image->thread_limit;
+ psize = sizeof(process_score) * image->server_limit;
+ ssize = sizeof(worker_score) * image->server_limit * image->thread_limit;
tsize = psize + ssize + sizeof(global_score) + sizeof(buf);
- /* fprintf(stderr, "sizes %d, %d, %d, %d, %d, %d\n",
- server_num, psize, ssize, sizeof(global_score) , sizeof(buf), tsize); */
-
+ /* fprintf(stderr, "sizes %d, %d, %d, %d, %d\n",
+ psize, ssize, sizeof(global_score) , sizeof(buf), tsize); */
+
data = (char *)apr_palloc(image->pool, tsize);
pack16(ptr, psize);
@@ -232,13 +224,13 @@
/* fill the data buffer with the data we want to freeze */
dptr = data;
- Move(buf, dptr, sizeof(buf), char);
+ Move(&buf[0], dptr, sizeof(buf), char);
dptr += sizeof(buf);
- Move(&sb->parent[0], dptr, psize, char);
+ Move(&sb->parent[0], dptr, psize, char);
dptr += psize;
- Move(&sb->servers[0], dptr, ssize, char);
+ Move(sb->servers[0], dptr, ssize, char);
dptr += ssize;
- Move(&sb->global, dptr, sizeof(global_score), char);
+ Move(&sb->global, dptr, sizeof(global_score), char);
/* an equivalent C function can return 'data', in case of XS it'll
* try to convert char *data to PV, using strlen(), which will
@@ -293,13 +285,16 @@
image->server_limit * sizeof(worker_score *));
sb->parent = (process_score *)Copy_pool(pool, ptr, psize, char);
ptr += psize;
+
sb->servers = (worker_score **)((char*)sb + sizeof(scoreboard));
for (i = 0; i < image->server_limit; i++) {
- sb->servers[i] = (worker_score *)Copy_pool(pool, ptr, sizeof(worker_score), char);
+ sb->servers[i] = (worker_score *)Copy_pool(pool, ptr,
+ sizeof(worker_score), char);
ptr += image->thread_limit * sizeof(worker_score);
}
- sb->global = (global_score *)ptr;
+ sb->global = (global_score *)Copy_pool(pool, ptr,
+ sizeof(global_score), char);
image->pool = pool;
image->sb = sb;
Modified: Apache-Scoreboard-2.0/trunk/apxs/send.c
==============================================================================
--- Apache-Scoreboard-2.0/trunk/apxs/send.c (original)
+++ Apache-Scoreboard-2.0/trunk/apxs/send.c Sat Feb 26 09:20:55 2005
@@ -31,24 +31,16 @@
static int scoreboard_send(request_rec *r)
{
- int server_num, psize, ssize, tsize;
+ int psize, ssize, tsize;
char buf[SIZE16*4];
char *ptr = buf;
int server_limit, thread_limit;
ap_mpm_query(AP_MPMQ_HARD_LIMIT_THREADS, &thread_limit);
ap_mpm_query(AP_MPMQ_HARD_LIMIT_DAEMONS, &server_limit);
-
- for (server_num = 0; server_num < server_limit; server_num++) {
- if (!ap_scoreboard_image->parent[server_num].pid) {
- break;
- }
- }
- server_num = server_limit;
-
- psize = sizeof(process_score) * server_num;
- ssize = sizeof(worker_score) * server_num * thread_limit;
+ psize = sizeof(process_score) * server_limit;
+ ssize = sizeof(worker_score) * server_limit * thread_limit;
tsize = psize + ssize + sizeof(global_score) + sizeof(buf);
pack16(ptr, psize);
@@ -61,12 +53,12 @@
#if 0
ap_log_error(APLOG_MARK, APLOG_ERR, 0, modperl_global_get_server_rec(),
- "send: sizes server_num=%d, thread_num=%d, psize=%d, "
+ "send: sizes server_limit=%d, thread_num=%d, psize=%d, "
"ssize=%d, %d, %d, %d\n",
- server_num, thread_limit, psize, ssize,
+ server_limit, thread_limit, psize, ssize,
sizeof(global_score), sizeof(buf), tsize);
#endif
-
+
ap_set_content_length(r, tsize);
r->content_type = REMOTE_SCOREBOARD_TYPE;
@@ -74,7 +66,7 @@
WRITE_BUFF(&buf[0], sizeof(buf), r);
WRITE_BUFF(&ap_scoreboard_image->parent[0], psize, r);
WRITE_BUFF(ap_scoreboard_image->servers[0], ssize, r);
- WRITE_BUFF(&ap_scoreboard_image->global, sizeof(global_score), r);
+ WRITE_BUFF(ap_scoreboard_image->global, sizeof(global_score), r);
}
return APR_SUCCESS;