scoreboard.c revision 26dfa083a1662d57ba7cc410eec4e0696b9be469
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000-2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
*
* Portions of this software are based upon public domain software
* originally written at the National Center for Supercomputing Applications,
* University of Illinois, Urbana-Champaign.
*/
#include "apr.h"
#include "apr_strings.h"
#include "apr_portable.h"
#include "apr_lib.h"
#define APR_WANT_STRFUNC
#include "apr_want.h"
#endif
#include "ap_config.h"
#include "httpd.h"
#include "http_log.h"
#include "http_main.h"
#include "http_core.h"
#include "http_config.h"
#include "ap_mpm.h"
#include "mpm.h"
#include "scoreboard.h"
AP_DECLARE_DATA int ap_extended_status = 0;
#include "apr_shm.h"
#endif
)
(p, sb_type))
struct ap_sb_handle_t {
int child_num;
int thread_num;
};
static int server_limit, thread_limit;
static apr_size_t scoreboard_size;
/*
* ToDo:
* This function should be renamed to cleanup_shared
* and it should handle cleaning up a scoreboard shared
* between processes using any form of IPC (file, shared memory
* segment, etc.). Leave it as is now because it is being used
* by various MPMs.
*/
static apr_status_t ap_cleanup_shared_mem(void *d)
{
#endif
return APR_SUCCESS;
}
int ap_calc_scoreboard_size(void)
{
scoreboard_size = sizeof(global_score);
return scoreboard_size;
}
void ap_init_scoreboard(void *shared_score)
{
char *more_storage;
int i;
more_storage += sizeof(global_score);
for (i = 0; i < server_limit; i++) {
}
}
/* ToDo: This function should be made to handle setting up
* a scoreboard shared between processes using any IPC technique,
* not just a shared memory segment
*/
{
if (ap_scoreboard_fname) {
}
if (rv != APR_SUCCESS) {
"Fatal error: could not open(create) scoreboard");
return rv;
}
/* everything will be cleared shortly */
#endif
return APR_SUCCESS;
}
/* If detach is non-zero, this is a seperate child process,
* if zero, it is a forked child.
*/
{
if (!detached) {
return APR_SUCCESS;
}
if (ap_scoreboard_fname) {
}
if (rv != APR_SUCCESS) {
"Fatal error: could not open(create) scoreboard");
return rv;
}
"Fatal error: shared scoreboard too small for child!");
}
/* everything will be cleared shortly */
#endif
return APR_SUCCESS;
}
apr_status_t ap_cleanup_scoreboard(void *d) {
if (ap_scoreboard_image == NULL)
return APR_SUCCESS;
}
else {
}
return APR_SUCCESS;
}
/* Create or reinit an existing scoreboard. The MPM can control whether
* the scoreboard is shared across multiple processes or not
*/
{
int running_gen = 0;
if (ap_scoreboard_image)
if (ap_scoreboard_image == NULL) {
void *sb_shared;
rv = open_scoreboard(p);
}
}
else if (sb_type == SB_SHARED_CHILD) {
void *sb_shared;
}
}
else {
/* A simple malloc will suffice */
"(%d)%s: cannot allocate scoreboard",
}
}
}
/* can't just memset() */
if (sb_type != SB_SHARED_CHILD) {
}
}
/* Routines called to deal with the scoreboard image
* --- note that we do *not* need write locks, since update_child_status
* only updates a *single* record in place, and only one process writes to
* a given scoreboard slot at a time (either the child process owning that
* slot, or the parent, noting that the child has died).
*
* As a final note --- setting the score entry to getpid() is always safe,
* since when the parent is writing an entry, it's only noting SERVER_DEAD
* anyway.
*/
void ap_sync_scoreboard_image(void)
{
}
AP_DECLARE(int) ap_exists_scoreboard_image(void)
{
return (ap_scoreboard_image ? 1 : 0);
}
{
/* XXX - needs to be fixed to account for threads */
#ifdef SCOREBOARD_FILE
+ (long) child_num * sizeof(worker_score), 0);
#endif
}
void update_scoreboard_global(void)
{
#ifdef SCOREBOARD_FILE
lseek(scoreboard_fd, 0, 0);
sizeof ap_scoreboard_image->global);
#endif
}
{
#ifdef HAVE_TIMES
#endif
ws->access_count++;
ws->my_access_count++;
ws->conn_count++;
}
{
int i;
int max_daemons_limit;
for (i = 0; i < max_daemons_limit; ++i)
return i;
return -1;
}
int child_num, int thread_num)
{
}
int status, request_rec *r)
{
int old_status;
if (child_num < 0)
return -1;
if (status == SERVER_READY
&& old_status == SERVER_STARTING) {
}
if (ap_extended_status) {
/*
* Reset individual counters
*/
if (status == SERVER_DEAD) {
ws->my_access_count = 0L;
ws->my_bytes_served = 0L;
}
ws->conn_count = (unsigned short) 0;
ws->conn_bytes = (unsigned long) 0;
}
if (r) {
conn_rec *c = r->connection;
if (r->the_request == NULL) {
} else {
/* Don't reveal the password in the server-status view */
}
}
}
return old_status;
}
{
status, r);
}
{
if (child_num < 0)
return;
if (status == START_PREQUEST) {
}
else if (status == STOP_PREQUEST) {
}
}
{
if (((x < 0) || (server_limit < x)) ||
((y < 0) || (thread_limit < y))) {
return(NULL); /* Out of range */
}
return(&ap_scoreboard_image->servers[x][y]);
}
{
if ((x < 0) || (server_limit < x)) {
return(NULL); /* Out of range */
}
return(&ap_scoreboard_image->parent[x]);
}
{
return(ap_scoreboard_image->global);
}