[svn:modperl-modules] rev 154 - Apache-Scoreboard-2.0/trunk
[email protected] 27 Feb 2005 05:24:40 -0000
| Newsgroups | perl.modperl.modules.svn |
|---|---|
| Message-ID | <[email protected]> |
Author: stas
Date: Sat Feb 26 21:24:39 2005
New Revision: 154
Modified:
Apache-Scoreboard-2.0/trunk/Changes
Apache-Scoreboard-2.0/trunk/Scoreboard.xs
Log:
make the worker happy
Modified: Apache-Scoreboard-2.0/trunk/Changes
==============================================================================
--- Apache-Scoreboard-2.0/trunk/Changes (original)
+++ Apache-Scoreboard-2.0/trunk/Changes Sat Feb 26 21:24:39 2005
@@ -1,10 +1,18 @@
2.05 -
+Apache::DummyScoreboard was ported to mp2 (this is used to process a
+scoreboard outside running Apache).
+
+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
+
added new methods $image->thread_limit and $image->server_limit and
deprecated the Apache::Const::SERVER_LIMIT and
-Apache::Const::THREAD_LIMIT constants, since those are useful only for
-the image of the Apache server inside which the script is run (if
-any).
+Apache::Const::THREAD_LIMIT constants, since those are correct and
+useful only for the image of the Apache server parsed from within the
+running server.
use the passed image object, rather than accessing the global
ap_scoreboard_image. Previously we have switched to use Apache
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 21:24:39 2005
@@ -189,28 +189,26 @@
Apache::RequestRec r
-
SV *
freeze(image)
Apache::Scoreboard image
PREINIT:
- int psize, ssize, tsize;
+ int psize, ssize, tsize, msize, i;
char buf[SIZE16*4];
- char *dptr, *data, *ptr = buf;
+ char *dptr, *ptr = buf;
scoreboard *sb;
CODE:
sb = image->sb;
psize = sizeof(process_score) * image->server_limit;
- ssize = sizeof(worker_score) * image->server_limit * image->thread_limit;
+ msize = sizeof(worker_score) * image->thread_limit;
+ ssize = msize * image->server_limit;
tsize = psize + ssize + sizeof(global_score) + sizeof(buf);
/* 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);
ptr += SIZE16;
pack16(ptr, ssize);
@@ -219,26 +217,25 @@
ptr += SIZE16;
pack16(ptr, image->thread_limit);
+ RETVAL = NEWSV(0, tsize);
+ dptr = SvPVX(RETVAL);
+ SvCUR_set(RETVAL, tsize+1);
+ SvPOK_only(RETVAL);
+
/* XXX: sync with send(), since the data frozen by this
* method won't work outside the same Apache */
/* fill the data buffer with the data we want to freeze */
- dptr = data;
Move(&buf[0], dptr, sizeof(buf), char);
dptr += sizeof(buf);
Move(&sb->parent[0], dptr, psize, char);
dptr += psize;
- Move(sb->servers[0], dptr, ssize, char);
- dptr += ssize;
+ for (i = 0; i < image->server_limit; i++) {
+ Move(sb->servers[i], dptr, msize, char);
+ dptr += msize;
+ }
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
- * lose data, since it won't continue past the first \0
- * char. Therefore in this case we explicitly return SV* and using
- * newSVpvn(data, tsize) to tell the exact size */
- RETVAL = newSVpvn(data, tsize);
-
OUTPUT:
RETVAL