[svn:modperl-modules] rev 182 - in Apache-Scoreboard-2.0/trunk: . apxs t/lib/MyTest
[email protected] 18 Mar 2005 18:38:42 -0000
| Newsgroups | perl.modperl.modules.svn |
|---|---|
| Message-ID | <[email protected]> |
Author: stas
Date: Fri Mar 18 10:38:42 2005
New Revision: 182
Modified:
Apache-Scoreboard-2.0/trunk/Changes
Apache-Scoreboard-2.0/trunk/Scoreboard.xs
Apache-Scoreboard-2.0/trunk/apxs/send.c
Apache-Scoreboard-2.0/trunk/t/lib/MyTest/Common.pm
Log:
- fix the buggy reconstruction of the fetched binary image in thaw
- better tracing of failing tests
Modified: Apache-Scoreboard-2.0/trunk/Changes
==============================================================================
--- Apache-Scoreboard-2.0/trunk/Changes (original)
+++ Apache-Scoreboard-2.0/trunk/Changes Fri Mar 18 10:38:42 2005
@@ -1,5 +1,7 @@
2.06 - dev
+fix the buggy reconstruction of the fetched binary image in thaw()
+
fix start_time(), stop_time() to return usecs as the second argument
Revamping docs (still needs more work)
Modified: Apache-Scoreboard-2.0/trunk/Scoreboard.xs
==============================================================================
--- Apache-Scoreboard-2.0/trunk/Scoreboard.xs (original)
+++ Apache-Scoreboard-2.0/trunk/Scoreboard.xs Fri Mar 18 10:38:42 2005
@@ -79,12 +79,12 @@
/* a worker that have served/serves at least one request and isn't
* dead yet */
-#define LIVE_WORKER(ws) ws->access_count != 0 || \
- ws->status != SERVER_DEAD
+#define LIVE_WORKER(ws) !(ws->access_count == 0 && ws->status == SERVER_DEAD)
/* a worker that does something at this very moment */
-#define ACTIVE_WORKER(ws) ws->access_count != 0 || \
- (ws->status != SERVER_DEAD && ws->status != SERVER_READY)
+#define ACTIVE_WORKER(ws) \
+ !(ws->access_count == 0 && \
+ (ws->status == SERVER_DEAD || ws->status == SERVER_READY))
#include "apxs/send.c"
@@ -163,6 +163,30 @@
#endif
}
+#ifdef DUMMY_SCOREBOARD
+#define MY_WARN fprintf(stderr,
+#else
+#define MY_WARN ap_log_error(APLOG_MARK, APLOG_ERR, 0, modperl_global_get_server_rec(),
+#endif
+
+#if 0
+static void debug_dump_sb(modperl_scoreboard_t *image)
+{
+ int i, j;
+
+ for (i = 0; i < image->server_limit; i++) {
+ for (j = 0; j < image->thread_limit; j++) {
+ worker_score *ws = &image->sb->servers[i][j];
+ if (ws->access_count) {
+ MY_WARN
+ "rcv %02d-%02d: stat: %c cnt: %d\n", i, j,
+ status_flags[ws->status],
+ (int)ws->access_count);
+ }
+ }
+ }
+}
+#endif
@@ -268,14 +292,13 @@
image->thread_limit = unpack16(ptr);
ptr += SIZE16;
- /* ap_log_error(APLOG_MARK, APLOG_ERR, 0, modperl_global_get_server_rec(), */
- /* fprintf(stderr,
+ /* MY_WARN
"recv: sizes server_num=%d, thread_num=%d, psize=%d, "
"ssize=%d\n",
image->server_limit, image->thread_limit, psize, ssize);
*/
- sb = (scoreboard *)apr_pcalloc(pool, sizeof(scoreboard) +
+ sb = (scoreboard *)apr_palloc(pool, sizeof(scoreboard) +
image->server_limit * sizeof(worker_score *));
sb->parent = (process_score *)Copy_pool(pool, ptr, psize, char);
ptr += psize;
@@ -283,7 +306,7 @@
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);
+ image->thread_limit * sizeof(worker_score), char);
ptr += image->thread_limit * sizeof(worker_score);
}
@@ -293,6 +316,8 @@
image->pool = pool;
image->sb = sb;
+ /* debug_dump_sb(image); */
+
RETVAL = image;
OUTPUT:
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 Fri Mar 18 10:38:42 2005
@@ -59,6 +59,23 @@
sizeof(global_score), sizeof(buf), tsize);
#endif
+#if 0
+{
+ int i, j;
+ for (i = 0; i < server_limit; i++) {
+ for (j = 0; j < thread_limit; j++) {
+ worker_score *ws = &ap_scoreboard_image->servers[i][j];
+ if (ws->access_count) {
+ ap_log_error(APLOG_MARK, APLOG_ERR, 0, modperl_global_get_server_rec(),
+ "snd %02d-%02d: stat: %c cnt: %d\n", i, j,
+ status_flags[ws->status],
+ (int)ws->access_count);
+ }
+ }
+ }
+}
+#endif
+
ap_set_content_length(r, tsize);
r->content_type = REMOTE_SCOREBOARD_TYPE;
Modified: Apache-Scoreboard-2.0/trunk/t/lib/MyTest/Common.pm
==============================================================================
--- Apache-Scoreboard-2.0/trunk/t/lib/MyTest/Common.pm (original)
+++ Apache-Scoreboard-2.0/trunk/t/lib/MyTest/Common.pm Fri Mar 18 10:38:42 2005
@@ -13,6 +13,10 @@
use File::Spec::Functions qw(catfile);
+# as we can't know ahead how many procs/workers are there, we can't
+# ok each value, in which case we will just look for faults when their
+# occur.
+
my $cfg = Apache::Test::config();
my $vars = $cfg->{vars};
@@ -144,6 +148,7 @@
$next_active_ok = 0 unless worker_score_is_ok($worker_score);
}
}
+
t_debug "parent ok";
ok $parent_ok;
t_debug "iterating over all workers";
@@ -166,7 +171,7 @@
my $up_time = $image->up_time;
t_debug "up_time: $up_time";
- ok $up_time;
+ ok $up_time >= 0; # can be 0 if tested too fast
my $worker_score = $image->worker_score(0, 0);
ok $worker_score;
@@ -229,22 +234,40 @@
my $ok = 1;
for (@worker_score_dual_ctx_props) {
my $res = $worker_score->$_();
- $ok = 0 unless defined $res;
+ unless (defined $res) {
+ $ok = 0;
+ warn "$_() failed: undefined\n";
+ }
my @res = $worker_score->$_();
- $ok = 0 unless @res;
+ unless (@res) {
+ $ok = 0;
+ warn "$_() failed: empty list\n";
+ }
}
# status: dual var
{
my $res = $worker_score->status();
- $ok = 0 unless $res/1 == $res;
- $ok = 0 unless $res =~ /^[\w\.]$/;
+ unless ($res/1 == $res) {
+ $ok = 0;
+ my $x = $res + 0;
+ warn "status()-in-numerical-context failed: " .
+ "not integer number: [$x]\n";
+ }
+ unless ($res =~ /^[\w\.]$/) {
+ $ok = 0;
+ warn "status()-in-string-context failed: got [$res]\n";
+ warn "access count: " , $worker_score->access_count(), "\n";
+ }
}
for (@worker_score_scalar_props) {
my $res = $worker_score->$_();
- $ok = 0 unless defined $res;
+ unless (defined $res) {
+ $ok = 0;
+ warn "$_() failed: undefined\n";
+ }
}
return $ok;