/usr/src/redhat/BUILD/httpd-2.2.3/include/scoreboard.h

説明を見る。
00001 /* Licensed to the Apache Software Foundation (ASF) under one or more
00002  * contributor license agreements.  See the NOTICE file distributed with
00003  * this work for additional information regarding copyright ownership.
00004  * The ASF licenses this file to You under the Apache License, Version 2.0
00005  * (the "License"); you may not use this file except in compliance with
00006  * the License.  You may obtain a copy of the License at
00007  *
00008  *     http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00022 #ifndef APACHE_SCOREBOARD_H
00023 #define APACHE_SCOREBOARD_H
00024 
00025 #ifdef __cplusplus
00026 extern "C" {
00027 #endif
00028 
00029 #ifdef HAVE_SYS_TIMES_H
00030 #include <sys/time.h>
00031 #include <sys/times.h>
00032 #elif defined(TPF)
00033 #include <time.h>
00034 #endif
00035 
00036 #include "ap_config.h"
00037 #include "apr_hooks.h"
00038 #include "apr_thread_proc.h"
00039 #include "apr_portable.h"
00040 #include "apr_shm.h"
00041 #include "apr_optional.h"
00042 
00043 /* Scoreboard file, if there is one */
00044 #ifndef DEFAULT_SCOREBOARD
00045 #define DEFAULT_SCOREBOARD "logs/apache_runtime_status"
00046 #endif
00047 
00048 /* Scoreboard info on a process is, for now, kept very brief --- 
00049  * just status value and pid (the latter so that the caretaker process
00050  * can properly update the scoreboard when a process dies).  We may want
00051  * to eventually add a separate set of long_score structures which would
00052  * give, for each process, the number of requests serviced, and info on
00053  * the current, or most recent, request.
00054  *
00055  * Status values:
00056  */
00057 
00058 #define SERVER_DEAD 0
00059 #define SERVER_STARTING 1       /* Server Starting up */
00060 #define SERVER_READY 2          /* Waiting for connection (or accept() lock) */
00061 #define SERVER_BUSY_READ 3      /* Reading a client request */
00062 #define SERVER_BUSY_WRITE 4     /* Processing a client request */
00063 #define SERVER_BUSY_KEEPALIVE 5 /* Waiting for more requests via keepalive */
00064 #define SERVER_BUSY_LOG 6       /* Logging the request */
00065 #define SERVER_BUSY_DNS 7       /* Looking up a hostname */
00066 #define SERVER_CLOSING 8        /* Closing the connection */
00067 #define SERVER_GRACEFUL 9       /* server is gracefully finishing request */
00068 #define SERVER_IDLE_KILL 10     /* Server is cleaning up idle children. */
00069 #define SERVER_NUM_STATUS 11    /* number of status settings */
00070 
00071 /* Type used for generation indicies.  Startup and every restart cause a
00072  * new generation of children to be spawned.  Children within the same
00073  * generation share the same configuration information -- pointers to stuff
00074  * created at config time in the parent are valid across children.  However,
00075  * this can't work effectively with non-forked architectures.  So while the
00076  * arrays in the scoreboard never change between the parent and forked
00077  * children, so they do not require shm storage, the contents of the shm
00078  * may contain no pointers.
00079  */
00080 typedef int ap_generation_t;
00081 
00082 /* Is the scoreboard shared between processes or not? 
00083  * Set by the MPM when the scoreboard is created.
00084  */
00085 typedef enum {
00086     SB_NOT_SHARED = 1,
00087     SB_SHARED = 2
00088 } ap_scoreboard_e;
00089 
00090 #define SB_WORKING  0  /* The server is busy and the child is useful. */
00091 #define SB_IDLE_DIE 1  /* The server is idle and the child is superfluous. */
00092                        /*   The child should check for this and exit gracefully. */
00093 
00094 /* stuff which is worker specific */
00095 /***********************WARNING***************************************/
00096 /* These are things that are used by mod_status. Do not put anything */
00097 /*   in here that you cannot live without. This structure will not   */
00098 /*   be available if mod_status is not loaded.                       */
00099 /*********************************************************************/
00100 typedef struct worker_score worker_score;
00101 
00102 struct worker_score {
00103     int thread_num;
00104 #if APR_HAS_THREADS
00105     apr_os_thread_t tid;
00106 #endif
00107     /* With some MPMs (e.g., worker), a worker_score can represent
00108      * a thread in a terminating process which is no longer
00109      * represented by the corresponding process_score.  These MPMs
00110      * should set pid and generation fields in the worker_score.
00111      */
00112     pid_t pid;
00113     ap_generation_t generation;
00114     unsigned char status;
00115     unsigned long access_count;
00116     apr_off_t     bytes_served;
00117     unsigned long my_access_count;
00118     apr_off_t     my_bytes_served;
00119     apr_off_t     conn_bytes;
00120     unsigned short conn_count;
00121     apr_time_t start_time;
00122     apr_time_t stop_time;
00123 #ifdef HAVE_TIMES
00124     struct tms times;
00125 #endif
00126     apr_time_t last_used;
00127     char client[32];            /* Keep 'em small... */
00128     char request[64];           /* We just want an idea... */
00129     char vhost[32];             /* What virtual host is being accessed? */
00130 };
00131 
00132 typedef struct {
00133     int             server_limit;
00134     int             thread_limit;
00135     ap_scoreboard_e sb_type;
00136     ap_generation_t running_generation; /* the generation of children which
00137                                          * should still be serving requests.
00138                                          */
00139     apr_time_t restart_time;
00140     int             lb_limit;
00141 } global_score;
00142 
00143 /* stuff which the parent generally writes and the children rarely read */
00144 typedef struct process_score process_score;
00145 struct process_score{
00146     pid_t pid;
00147     ap_generation_t generation; /* generation of this child */
00148     ap_scoreboard_e sb_type;
00149     int quiescing;          /* the process whose pid is stored above is
00150                              * going down gracefully
00151                              */
00152 };
00153 
00154 /* stuff which is lb specific */
00155 typedef struct lb_score lb_score;
00156 struct lb_score{
00157     /* TODO: make a real stuct from this */
00158     unsigned char data[1024];
00159 };
00160 
00161 /* Scoreboard is now in 'local' memory, since it isn't updated once created,
00162  * even in forked architectures.  Child created-processes (non-fork) will
00163  * set up these indicies into the (possibly relocated) shmem records.
00164  */
00165 typedef struct {
00166     global_score *global;
00167     process_score *parent;
00168     worker_score **servers;
00169     lb_score     *balancers;
00170 } scoreboard;
00171 
00172 typedef struct ap_sb_handle_t ap_sb_handle_t;
00173 
00174 AP_DECLARE(int) ap_exists_scoreboard_image(void);
00175 AP_DECLARE(void) ap_increment_counts(ap_sb_handle_t *sbh, request_rec *r);
00176 
00177 int ap_create_scoreboard(apr_pool_t *p, ap_scoreboard_e t);
00178 apr_status_t ap_reopen_scoreboard(apr_pool_t *p, apr_shm_t **shm, int detached);
00179 void ap_init_scoreboard(void *shared_score);
00180 AP_DECLARE(int) ap_calc_scoreboard_size(void);
00181 apr_status_t ap_cleanup_scoreboard(void *d);
00182 
00183 AP_DECLARE(void) ap_create_sb_handle(ap_sb_handle_t **new_sbh, apr_pool_t *p,
00184                                      int child_num, int thread_num);
00185     
00186 int find_child_by_pid(apr_proc_t *pid);
00187 AP_DECLARE(int) ap_update_child_status(ap_sb_handle_t *sbh, int status, request_rec *r);
00188 AP_DECLARE(int) ap_update_child_status_from_indexes(int child_num, int thread_num,
00189                                                     int status, request_rec *r);
00190 void ap_time_process_request(ap_sb_handle_t *sbh, int status);
00191 
00192 AP_DECLARE(worker_score *) ap_get_scoreboard_worker(int x, int y);
00193 AP_DECLARE(process_score *) ap_get_scoreboard_process(int x);
00194 AP_DECLARE(global_score *) ap_get_scoreboard_global(void);
00195 AP_DECLARE(lb_score *) ap_get_scoreboard_lb(int lb_num);
00196 
00197 AP_DECLARE_DATA extern scoreboard *ap_scoreboard_image;
00198 AP_DECLARE_DATA extern const char *ap_scoreboard_fname;
00199 AP_DECLARE_DATA extern int ap_extended_status;
00200 
00201 AP_DECLARE_DATA extern ap_generation_t volatile ap_my_generation;
00202 
00203 /* Hooks */
00211 AP_DECLARE_HOOK(int, pre_mpm, (apr_pool_t *p, ap_scoreboard_e sb_type))
00212 
00217 APR_DECLARE_OPTIONAL_FN(int, ap_proxy_lb_workers,
00218                         (void));
00219 
00220 /* for time_process_request() in http_main.c */
00221 #define START_PREQUEST 1
00222 #define STOP_PREQUEST  2
00223 
00224 #ifdef __cplusplus
00225 }
00226 #endif
00227 
00228 #endif  /* !APACHE_SCOREBOARD_H */

Apacheに対してSun Jul 19 22:05:23 2009に生成されました。  doxygen 1.4.7