Apache2-ScoreBoardFile
view release on metacpan or search on metacpan
ScoreBoardFile "/path/to/scoreboard.sb"
Perl level:
use Apache2::ScoreBoardFile;
$sb=Apache2::ScoreBoardFile->new($filename);
$sb=Apache2::ScoreBoardFile->new($filehandle);
$shared_mem_size=$sb->shmsize;
$server_limit=$sb->server_limit;
$thread_limit=$sb->thread_limit;
$type=$sb->type;
$generation=$sb->generation;
$lb_limit=$sb->lb_limit;
$restart_time=$sb->restart_time;
$process=$sb->process($index);
$pid=$process->pid;
$generation=$process->generation;
$quiescing=$process->quiescing;
$worker=$sb->worker($index);
$worker=$sb->worker($proc_index, $thread_index);
$thread_num=$worker->thread_num;
$pid=$worker->pid;
$generation=$worker->generation;
$status=$worker->status;
$access_count=$worker->access_count;
$bytes_served=$worker->bytes_served;
$my_access_count=$worker->my_access_count;
$my_bytes_served=$worker->my_bytes_served;
$conn_count=$worker->conn_count;
$conn_bytes=$worker->conn_bytes;
$start_time=$worker->start_time;
$sb=Apache2::ScoreBoardFile->new($filename_or_handle);
the constructor. The parameter is either the name of the scoreboard file
or an open file handle.
$shared_mem_size=$sb->shmsize;
the shared memory size.
$server_limit=$sb->server_limit;
see "ServerLimit" in Apache HTTP Server Documentation.
$thread_limit=$sb->thread_limit;
see "ThreadLimit" in Apache HTTP Server Documentation.
$type=$sb->type;
the type of the scoreboard. See include/scoreboard.h in your apache
distribution. This value should contain 2 which means "SB_SHARED".
Please drop me a mail if it says otherwise in your installation.
$generation=$sb->generation;
the server generation (number of times it has been restarted by "SIGHUP"
or "SIGUSR1")
the server is performing a restart and this process belongs to the old
generation.
$quiescing=$process->quiescing;
if true the process is going down gracefully.
$worker=$sb->worker($index);
returns an "Apache2::ScoreBoardFile::Worker" object by its overall
index.
$worker=$sb->worker($proc_index, $thread_index);
returns an "Apache2::ScoreBoardFile::Worker" object by its process index
and the thread index within the process.
$thread_num=$worker->thread_num;
returns the overall index of a worker
$pid=$worker->pid;
with prefork-MPM this field is unused. include/scoreboard.h explains:
/* With some MPMs (e.g., worker), a worker_score can represent
* a thread in a terminating process which is no longer
* represented by the corresponding process_score. These MPMs
* should set pid and generation fields in the worker_score.
*/
$generation=$worker->generation;
with prefork-MPM this field is unused. include/scoreboard.h explains:
/* With some MPMs (e.g., worker), a worker_score can represent
* a thread in a terminating process which is no longer
* represented by the corresponding process_score. These MPMs
* should set pid and generation fields in the worker_score.
*/
$status=$worker->status;
the status of a worker as one of the letters seen on the "mod_status"
page:
"_" Waiting for Connection
"S" Starting up
ScoreBoardFile.xs view on Meta::CPAN
return -1;
}
static inline void
collect_summary(Apache2__ScoreBoardFile obj, struct summary *result, int len) {
int i, j, k, plim, tlim;
worker_score *ws;
process_score *ps;
plim=obj->gscore.server_limit;
tlim=obj->gscore.thread_limit;
for(i=0; i<plim; i++) {
ps=&(obj->pscore[i]);
for(j=0; j<tlim; j++) {
ws=&(((worker_score*)(&(obj->pscore[plim])))[tlim*i+j]);
/*warn("i: %d, j=%d, pid: %d, status: %c\n",
i, j, (ws->pid ? ws->pid : ps->pid),
(ws->status<sizeof(ws_status_letters)-1 ? ws_status_letters[ws->status] : '?'));*/
for(k=0; k<len; k++) {
if( result[k].what<0 ) {
switch(result[k].what) {
ScoreBoardFile.xs view on Meta::CPAN
unsigned int
server_limit(obj)
Apache2::ScoreBoardFile obj
PROTOTYPE: $
CODE:
RETVAL=obj->gscore.server_limit;
OUTPUT:
RETVAL
unsigned int
thread_limit(obj)
Apache2::ScoreBoardFile obj
PROTOTYPE: $
CODE:
RETVAL=obj->gscore.thread_limit;
OUTPUT:
RETVAL
unsigned int
type(obj)
Apache2::ScoreBoardFile obj
PROTOTYPE: $
CODE:
RETVAL=obj->gscore.sb_type;
OUTPUT:
ScoreBoardFile.xs view on Meta::CPAN
RETVAL
Apache2::ScoreBoardFile::Worker
worker(obj, pindex, tindex=-1)
Apache2::ScoreBoardFile obj
unsigned int pindex
unsigned int tindex
PROTOTYPE: $$;$
INIT:
int sl=obj->gscore.server_limit;
int tl=obj->gscore.thread_limit;
if( items>2 ) pindex=tl*pindex+tindex; /* 2 indices: procnr, threadnr */
if( !(0<=pindex && pindex<sl*tl) ) XSRETURN_UNDEF;
CODE:
/* warn("sl=%d, tl=%d, start_of_ws=%x\n", sl, tl, */
/* (char*)(&(obj->pscore[sl]))-(char*)obj); */
RETVAL=&(((worker_score*)(&(obj->pscore[sl])))[pindex]);
OUTPUT:
RETVAL
void
DESTROY(obj)
ScoreBoardFile.xs view on Meta::CPAN
Apache2::ScoreBoardFile::Process obj
PROTOTYPE: $
CODE:
RETVAL=obj->quiescing;
OUTPUT:
RETVAL
MODULE = Apache2::ScoreBoardFile PACKAGE = Apache2::ScoreBoardFile::Worker
int
thread_num(obj)
Apache2::ScoreBoardFile::Worker obj
PROTOTYPE: $
CODE:
RETVAL=obj->thread_num;
OUTPUT:
RETVAL
unsigned int
pid(obj)
Apache2::ScoreBoardFile::Worker obj
PROTOTYPE: $
CODE:
RETVAL=obj->pid;
OUTPUT:
lib/Apache2/ScoreBoardFile.pm view on Meta::CPAN
ScoreBoardFile "/path/to/scoreboard.sb"
Perl level:
use Apache2::ScoreBoardFile;
$sb=Apache2::ScoreBoardFile->new($filename);
$sb=Apache2::ScoreBoardFile->new($filehandle);
$shared_mem_size=$sb->shmsize;
$server_limit=$sb->server_limit;
$thread_limit=$sb->thread_limit;
$type=$sb->type;
$generation=$sb->generation;
$lb_limit=$sb->lb_limit;
$restart_time=$sb->restart_time;
$process=$sb->process($index);
$pid=$process->pid;
$generation=$process->generation;
$quiescing=$process->quiescing;
$worker=$sb->worker($index);
$worker=$sb->worker($proc_index, $thread_index);
$thread_num=$worker->thread_num;
$pid=$worker->pid;
$generation=$worker->generation;
$status=$worker->status;
$access_count=$worker->access_count;
$bytes_served=$worker->bytes_served;
$my_access_count=$worker->my_access_count;
$my_bytes_served=$worker->my_bytes_served;
$conn_count=$worker->conn_count;
$conn_bytes=$worker->conn_bytes;
$start_time=$worker->start_time;
lib/Apache2/ScoreBoardFile.pm view on Meta::CPAN
open file handle.
=head3 $shared_mem_size=$sb-E<gt>shmsize;
the shared memory size.
=head3 $server_limit=$sb-E<gt>server_limit;
see C<ServerLimit> in Apache HTTP Server Documentation.
=head3 $thread_limit=$sb-E<gt>thread_limit;
see C<ThreadLimit> in Apache HTTP Server Documentation.
=head3 $type=$sb-E<gt>type;
the type of the scoreboard. See F<include/scoreboard.h> in your apache
distribution. This value should contain C<2> which means C<SB_SHARED>.
Please drop me a mail if it says otherwise in your installation.
=head3 $generation=$sb-E<gt>generation;
lib/Apache2/ScoreBoardFile.pm view on Meta::CPAN
generation.
=head3 $quiescing=$process-E<gt>quiescing;
if true the process is going down gracefully.
=head3 $worker=$sb-E<gt>worker($index);
returns an C<Apache2::ScoreBoardFile::Worker> object by its overall index.
=head3 $worker=$sb-E<gt>worker($proc_index, $thread_index);
returns an C<Apache2::ScoreBoardFile::Worker> object by its process index
and the thread index within the process.
=head3 $thread_num=$worker-E<gt>thread_num;
returns the overall index of a worker
=head3 $pid=$worker-E<gt>pid;
with prefork-MPM this field is unused. F<include/scoreboard.h> explains:
/* With some MPMs (e.g., worker), a worker_score can represent
* a thread in a terminating process which is no longer
* represented by the corresponding process_score. These MPMs
* should set pid and generation fields in the worker_score.
*/
=head3 $generation=$worker-E<gt>generation;
with prefork-MPM this field is unused. F<include/scoreboard.h> explains:
/* With some MPMs (e.g., worker), a worker_score can represent
* a thread in a terminating process which is no longer
* represented by the corresponding process_score. These MPMs
* should set pid and generation fields in the worker_score.
*/
=head3 $status=$worker-E<gt>status;
the status of a worker as one of the letters seen on the C<mod_status>
page:
"_" Waiting for Connection
new_version||5.009000|
new_warnings_bitfield|||
next_symbol|||
nextargv|||
nextchar|||
ninstr|||
no_bareword_allowed|||
no_fh_allowed|||
no_op|||
not_a_number|||
nothreadhook||5.008000|
nuke_stacks|||
num_overflow|||n
offer_nice_chunk|||
oopsAV|||
oopsHV|||
op_clear|||
op_const_sv|||
op_dump||5.006000|
op_free|||
op_getmad_weak|||
U32 DPPP_(my_PL_signals) = D_PPP_PERL_SIGNALS_INIT;
#else
extern U32 DPPP_(my_PL_signals);
#endif
#define PL_signals DPPP_(my_PL_signals)
#endif
/* Hint: PL_ppaddr
* Calling an op via PL_ppaddr requires passing a context argument
* for threaded builds. Since the context argument is different for
* 5.005 perls, you can use aTHXR (supplied by ppport.h), which will
* automatically be defined as the correct argument.
*/
#if (PERL_BCDVERSION <= 0x5005005)
/* Replace: 1 */
# define PL_ppaddr ppaddr
# define PL_no_modify no_modify
/* Replace: 0 */
#endif
PL_curcop->cop_stash = old_cop_stash;
PL_curstash = old_curstash;
PL_curcop->cop_line = oldline;
}
#endif
#endif
/*
* Boilerplate macros for initializing and accessing interpreter-local
* data from C. All statics in extensions should be reworked to use
* this, if you want to make the extension thread-safe. See ext/re/re.xs
* for an example of the use of these macros.
*
* Code that uses these macros is responsible for the following:
* 1. #define MY_CXT_KEY to a unique string, e.g. "DynaLoader_guts"
* 2. Declare a typedef named my_cxt_t that is a structure that contains
* all the data that needs to be interpreter-local.
* 3. Use the START_MY_CXT macro after the declaration of my_cxt_t.
* 4. Use the MY_CXT_INIT macro such that it is called exactly once
* (typically put in the BOOT: section).
* 5. Use the members of the my_cxt_t structure everywhere as
* 6. Use the dMY_CXT macro (a declaration) in all the functions that
* access MY_CXT.
*/
#if defined(MULTIPLICITY) || defined(PERL_OBJECT) || \
defined(PERL_CAPI) || defined(PERL_IMPLICIT_CONTEXT)
#ifndef START_MY_CXT
/* This must appear in all extensions that define a my_cxt_t structure,
* right after the definition (i.e. at file scope). The non-threads
* case below uses it to declare the data as static. */
#define START_MY_CXT
#if (PERL_BCDVERSION < 0x5004068)
/* Fetches the SV that keeps the per-interpreter data. */
#define dMY_CXT_SV \
SV *my_cxt_sv = get_sv(MY_CXT_KEY, FALSE)
#else /* >= perl5.004_68 */
#define dMY_CXT_SV \
SV *my_cxt_sv = *hv_fetch(PL_modglobal, MY_CXT_KEY, \
if (*sp + len <= send && memEQ(*sp, radix, len)) {
*sp += len;
return TRUE;
}
}
#else
/* older perls don't have PL_numeric_radix_sv so the radix
* must manually be requested from locale.h
*/
#include <locale.h>
dTHR; /* needed for older threaded perls */
struct lconv *lc = localeconv();
char *radix = lc->decimal_point;
if (radix && IN_LOCALE) {
STRLEN len = strlen(radix);
if (*sp + len <= send && memEQ(*sp, radix, len)) {
*sp += len;
return TRUE;
}
}
#endif
t_debug $obj->restart_time." >= ".((stat $pidfile)[9]-1);
ok $obj->restart_time>=(stat $pidfile)[9]-1, 'restart_time >= mtime(pidfile)-1';
my $gen=$obj->generation;
cmp_ok $gen, '>=', 0, 'current generation>=0';
is $obj->type, 2, 'type=SB_SHARED';
is $obj->server_limit, 16, "ServerLimit 16 (extra.conf.in)";
for (qw/shmsize server_limit thread_limit type generation
restart_time lb_limit/) {
t_debug "$_: ".$obj->$_;
}
t_start_error_log_watch;
{
local $/;
local @ARGV=($pidfile);
my $pid=0+<>;
t_debug "httpd pid=$pid";
$count++ if $obj->process($i)->pid;
}
is $count, 3, 'StartServers 3 - found '.$count;
ok !defined($obj->process(17)), 'process(17) - undef (out of range)';
ok !defined($obj->process(-1)), 'process(-1) - undef (out of range)';
$count=0;
for( my $i=0; $i<16; $i++ ) {
$count+=$obj->worker($i)->thread_num;
}
is $count, 3, 'sum(thread_num)==3';
$count=join "", map {$obj->worker($_)->status} 0..15;
t_debug "status: $count";
is $count=~tr/_//, 3, '3 ready worker (status _)';
t_debug "access_count: ".join ", ", map {$obj->worker($_)->access_count} 0..15;
$count=0;
for( my $i=0; $i<16; $i++ ) {
$count+=$obj->worker($i)->access_count;
}
( run in 0.674 second using v1.01-cache-2.11-cpan-3cd7ad12f66 )