Stas Bekman wrote:
I'm not sure if it's related, but this:
------------------------------------------ #!/usr/bin/perl -w use strict; $|++; use Apache::Scoreboard; my $image=Apache::Scoreboard->fetch("[a scoreboard url]"); for (my $parent = $image->parent; $parent; $parent = $parent->next) { my $server = $parent->server; #Apache::ServerScore object print $server->vhost,"\n"; } ------------------------------------------
still segfults on my machine. VMonitor is working fine, though.
Yup, I get it too. Blame the lack of the test suite. Hopefully we will gradually create one. I'm starting with your test cases that you've reported.
What happen is that when you call fetch, you get a copy of the image. Which works fine for most things, since they are inlined. The vhost record is however a pointer to another struct, which is not part of that image. so when it's attempted to be resolved outside of running Apache, it segfaults. It works fine under Apache::VMonitor since the latter runs under Apache, so the pointer is resolved w/o a problem.
For now the following simply disables vhosts for Apache::DummyScoreboard (which is the one used when modperl is not loaded).
Index: Scoreboard.xs =================================================================== --- Scoreboard.xs (revision 127) +++ Scoreboard.xs (working copy) @@ -32,8 +32,10 @@ #define server_score_client(s) s->record.client #define server_score_request(s) s->record.request
-#define server_score_vhost(s) \ - s->record.vhostrec ? s->record.vhostrec->server_hostname : "" +#define server_score_vhost(s) \ + s->record.vhostrec && ap_scoreboard_image \ + ? s->record.vhostrec->server_hostname \ + : ""
#define parent_score_pid(s) s->record.pid
I suppose we could copy the vhost record's string into:
typedef struct { parent_score record; int idx; scoreboard *image; } Apache__parent_score;
e.g. by adding:
char [128] vhost;
but it'll slow down the general case. So it probably requires some thinking. May be it could be optional and used only for external image fetching and referred to, if detected that we aren't running under Apache, e.g.:
ap_scoreboard_image ? (s->record.vhostrec ? s->record.vhostrec->server_hostname : "") : (s->vhost)
-- __________________________________________________________________ Stas Bekman JAm_pH ------> Just Another mod_perl Hacker http://stason.org/ mod_perl Guide ---> http://perl.apache.org mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com