scoreboard.h revision 38bdd984873c6293e6651dbac48884442b5842a9
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein/* ====================================================================
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * The Apache Software License, Version 1.1
b99dbaab171d91e1b664397cc40e039d0c087c65fielding * Copyright (c) 2000-2001 The Apache Software Foundation. All rights
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * reserved.
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * Redistribution and use in source and binary forms, with or without
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * modification, are permitted provided that the following conditions
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * 1. Redistributions of source code must retain the above copyright
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * notice, this list of conditions and the following disclaimer.
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * 2. Redistributions in binary form must reproduce the above copyright
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * notice, this list of conditions and the following disclaimer in
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * the documentation and/or other materials provided with the
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * distribution.
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * 3. The end-user documentation included with the redistribution,
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * if any, must include the following acknowledgment:
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * "This product includes software developed by the
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * Apache Software Foundation (http://www.apache.org/)."
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * Alternately, this acknowledgment may appear in the software itself,
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * if and wherever such third-party acknowledgments normally appear.
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * 4. The names "Apache" and "Apache Software Foundation" must
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * not be used to endorse or promote products derived from this
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * software without prior written permission. For written
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * permission, please contact apache@apache.org.
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * 5. Products derived from this software may not be called "Apache",
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * nor may "Apache" appear in their name, without prior written
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * permission of the Apache Software Foundation.
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * SUCH DAMAGE.
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * ====================================================================
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * This software consists of voluntary contributions made by many
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * individuals on behalf of the Apache Software Foundation. For more
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * information on the Apache Software Foundation, please see
f4c310fd2555c6faca1f980f00b161eadb089023gstein * Portions of this software are based upon public domain software
f4c310fd2555c6faca1f980f00b161eadb089023gstein * originally written at the National Center for Supercomputing Applications,
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * University of Illinois, Urbana-Champaign.
1b21d7b3d97def358b2e923655edeb16613a1c31gsteinextern "C" {
f4c310fd2555c6faca1f980f00b161eadb089023gstein/* Scoreboard info on a process is, for now, kept very brief ---
f4c310fd2555c6faca1f980f00b161eadb089023gstein * just status value and pid (the latter so that the caretaker process
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm * can properly update the scoreboard when a process dies). We may want
f4c310fd2555c6faca1f980f00b161eadb089023gstein * to eventually add a separate set of long_score structures which would
f4c310fd2555c6faca1f980f00b161eadb089023gstein * give, for each process, the number of requests serviced, and info on
f4c310fd2555c6faca1f980f00b161eadb089023gstein * the current, or most recent, request.
f4c310fd2555c6faca1f980f00b161eadb089023gstein * Status values:
f4c310fd2555c6faca1f980f00b161eadb089023gstein#define SERVER_READY 2 /* Waiting for connection (or accept() lock) */
f4c310fd2555c6faca1f980f00b161eadb089023gstein#define SERVER_BUSY_READ 3 /* Reading a client request */
98e9c4a310bb623ff788680f88b6bd200ff36a24wrowe#define SERVER_BUSY_WRITE 4 /* Processing a client request */
98e9c4a310bb623ff788680f88b6bd200ff36a24wrowe#define SERVER_BUSY_KEEPALIVE 5 /* Waiting for more requests via keepalive */
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm#define SERVER_GRACEFUL 8 /* server is gracefully finishing request */
f4c310fd2555c6faca1f980f00b161eadb089023gstein#define SERVER_ACCEPTING 9 /* thread is accepting connections */
f4c310fd2555c6faca1f980f00b161eadb089023gstein#define SERVER_QUEUEING 10 /* thread is putting connection on the queue */
f4c310fd2555c6faca1f980f00b161eadb089023gstein#define SERVER_IDLE_KILL 11 /* Server is cleaning up idle children. */
f4c310fd2555c6faca1f980f00b161eadb089023gstein#define SERVER_NUM_STATUS 12 /* number of status settings */
f4c310fd2555c6faca1f980f00b161eadb089023gstein/* Type used for generation indicies. Startup and every restart cause a
f4c310fd2555c6faca1f980f00b161eadb089023gstein * new generation of children to be spawned. Children within the same
f4c310fd2555c6faca1f980f00b161eadb089023gstein * generation share the same configuration information -- pointers to stuff
f4c310fd2555c6faca1f980f00b161eadb089023gstein * created at config time in the parent are valid across children. For
98e9c4a310bb623ff788680f88b6bd200ff36a24wrowe * example, the vhostrec pointer in the scoreboard below is valid in all
98e9c4a310bb623ff788680f88b6bd200ff36a24wrowe * children of the same generation.
f4c310fd2555c6faca1f980f00b161eadb089023gstein * The safe way to access the vhost pointer is like this:
f4c310fd2555c6faca1f980f00b161eadb089023gstein * worker_score *ss = pointer to whichver slot is interesting;
f4c310fd2555c6faca1f980f00b161eadb089023gstein * process_score *ps = pointer to whichver slot is interesting;
f4c310fd2555c6faca1f980f00b161eadb089023gstein * server_rec *vh = ss->vhostrec;
f4c310fd2555c6faca1f980f00b161eadb089023gstein * if (ps->generation != ap_my_generation) {
f4c310fd2555c6faca1f980f00b161eadb089023gstein * vh = NULL;
f4c310fd2555c6faca1f980f00b161eadb089023gstein * then if vh is not NULL it's valid in this child.
98e9c4a310bb623ff788680f88b6bd200ff36a24wrowe * This avoids various race conditions around restarts.
f4c310fd2555c6faca1f980f00b161eadb089023gstein/* Is the scoreboard shared between processes or not?
f4c310fd2555c6faca1f980f00b161eadb089023gstein * Set by the MPM when the scoreboard is created.
f4c310fd2555c6faca1f980f00b161eadb089023gsteintypedef enum {
f4c310fd2555c6faca1f980f00b161eadb089023gstein#define SB_WORKING 0 /* The server is busy and the child is useful. */
f4c310fd2555c6faca1f980f00b161eadb089023gstein#define SB_IDLE_DIE 1 /* The server is idle and the child is superfluous. */
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm /* The child should check for this and exit gracefully. */
f4c310fd2555c6faca1f980f00b161eadb089023gstein/* stuff which is worker specific */
f4c310fd2555c6faca1f980f00b161eadb089023gstein/***********************WARNING***************************************/
f4c310fd2555c6faca1f980f00b161eadb089023gstein/* These are things that are used by mod_status. Do not put anything */
f4c310fd2555c6faca1f980f00b161eadb089023gstein/* in here that you cannot live without. This structure will not */
f4c310fd2555c6faca1f980f00b161eadb089023gstein/* be available if mod_status is not loaded. */
98e9c4a310bb623ff788680f88b6bd200ff36a24wrowe/*********************************************************************/
98e9c4a310bb623ff788680f88b6bd200ff36a24wrowe unsigned char status;
98e9c4a310bb623ff788680f88b6bd200ff36a24wrowe unsigned long access_count;
f4c310fd2555c6faca1f980f00b161eadb089023gstein unsigned long bytes_served;
f4c310fd2555c6faca1f980f00b161eadb089023gstein unsigned long my_access_count;
f4c310fd2555c6faca1f980f00b161eadb089023gstein unsigned long my_bytes_served;
f4c310fd2555c6faca1f980f00b161eadb089023gstein unsigned long conn_bytes;
f4c310fd2555c6faca1f980f00b161eadb089023gstein unsigned short conn_count;
f4c310fd2555c6faca1f980f00b161eadb089023gstein server_rec *vhostrec; /* What virtual host is being accessed? */
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* SEE ABOVE FOR SAFE USAGE! */
f4c310fd2555c6faca1f980f00b161eadb089023gsteintypedef struct {
98e9c4a310bb623ff788680f88b6bd200ff36a24wrowe ap_generation_t running_generation; /* the generation of children which
98e9c4a310bb623ff788680f88b6bd200ff36a24wrowe * should still be serving requests. */
f4c310fd2555c6faca1f980f00b161eadb089023gstein/* stuff which the parent generally writes and the children rarely read */
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_generation_t generation; /* generation of this child */
f4c310fd2555c6faca1f980f00b161eadb089023gstein unsigned short process_status; /* Either SB_WORKING or SB_IDLE_DIE */
48f35e10f195dd594d75738fc536bb885eda537cgsteintypedef struct {
f4c310fd2555c6faca1f980f00b161eadb089023gstein worker_score servers[HARD_SERVER_LIMIT][HARD_THREAD_LIMIT];
f4c310fd2555c6faca1f980f00b161eadb089023gsteintypedef struct {
f4c310fd2555c6faca1f980f00b161eadb089023gsteinAP_DECLARE(void) ap_create_scoreboard(apr_pool_t *p, ap_scoreboard_e t);
f4c310fd2555c6faca1f980f00b161eadb089023gsteinAP_DECLARE(void) ap_increment_counts(int child_num, int thread_num, request_rec *r);
f4c310fd2555c6faca1f980f00b161eadb089023gsteinint ap_update_child_status(int child_num, int thread_num, int status, request_rec *r);
f4c310fd2555c6faca1f980f00b161eadb089023gsteinvoid ap_time_process_request(int child_num, int thread_num, int status);
48f35e10f195dd594d75738fc536bb885eda537cgsteinAP_DECLARE_DATA extern scoreboard *ap_scoreboard_image;
48f35e10f195dd594d75738fc536bb885eda537cgsteinAP_DECLARE_DATA extern const char *ap_scoreboard_fname;
48f35e10f195dd594d75738fc536bb885eda537cgsteinAP_DECLARE_DATA extern ap_generation_t volatile ap_my_generation;
48f35e10f195dd594d75738fc536bb885eda537cgstein/* for time_process_request() in http_main.c */
48f35e10f195dd594d75738fc536bb885eda537cgstein#endif /* !APACHE_SCOREBOARD_H */