00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
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
00044 #ifndef DEFAULT_SCOREBOARD
00045 #define DEFAULT_SCOREBOARD "logs/apache_runtime_status"
00046 #endif
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058 #define SERVER_DEAD 0
00059 #define SERVER_STARTING 1
00060 #define SERVER_READY 2
00061 #define SERVER_BUSY_READ 3
00062 #define SERVER_BUSY_WRITE 4
00063 #define SERVER_BUSY_KEEPALIVE 5
00064 #define SERVER_BUSY_LOG 6
00065 #define SERVER_BUSY_DNS 7
00066 #define SERVER_CLOSING 8
00067 #define SERVER_GRACEFUL 9
00068 #define SERVER_IDLE_KILL 10
00069 #define SERVER_NUM_STATUS 11
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080 typedef int ap_generation_t;
00081
00082
00083
00084
00085 typedef enum {
00086 SB_NOT_SHARED = 1,
00087 SB_SHARED = 2
00088 } ap_scoreboard_e;
00089
00090
00091 typedef struct worker_score worker_score;
00092 struct worker_score {
00093 int thread_num;
00094 #if APR_HAS_THREADS
00095 apr_os_thread_t tid;
00096 #endif
00097
00098
00099
00100
00101
00102 pid_t pid;
00103 ap_generation_t generation;
00104 unsigned char status;
00105 unsigned long access_count;
00106 apr_off_t bytes_served;
00107 unsigned long my_access_count;
00108 apr_off_t my_bytes_served;
00109 apr_off_t conn_bytes;
00110 unsigned short conn_count;
00111 apr_time_t start_time;
00112 apr_time_t stop_time;
00113 #ifdef HAVE_TIMES
00114 struct tms times;
00115 #endif
00116 apr_time_t last_used;
00117 char client[32];
00118 char request[64];
00119 char vhost[32];
00120 };
00121
00122 typedef struct {
00123 int server_limit;
00124 int thread_limit;
00125 ap_scoreboard_e sb_type;
00126 ap_generation_t running_generation;
00127
00128
00129 apr_time_t restart_time;
00130 int lb_limit;
00131 } global_score;
00132
00133
00134 typedef struct process_score process_score;
00135 struct process_score {
00136 pid_t pid;
00137 ap_generation_t generation;
00138 ap_scoreboard_e sb_type;
00139 int quiescing;
00140
00141
00142 };
00143
00144
00145 typedef struct lb_score lb_score;
00146 struct lb_score {
00147
00148 unsigned char data[1024];
00149 };
00150
00151
00152
00153
00154
00155 typedef struct {
00156 global_score *global;
00157 process_score *parent;
00158 worker_score **servers;
00159 lb_score *balancers;
00160 } scoreboard;
00161
00162 typedef struct ap_sb_handle_t ap_sb_handle_t;
00163
00164 AP_DECLARE(int) ap_exists_scoreboard_image(void);
00165 AP_DECLARE(void) ap_increment_counts(ap_sb_handle_t *sbh, request_rec *r);
00166
00167 int ap_create_scoreboard(apr_pool_t *p, ap_scoreboard_e t);
00168 apr_status_t ap_reopen_scoreboard(apr_pool_t *p, apr_shm_t **shm, int detached);
00169 void ap_init_scoreboard(void *shared_score);
00170 AP_DECLARE(int) ap_calc_scoreboard_size(void);
00171 apr_status_t ap_cleanup_scoreboard(void *d);
00172
00173 AP_DECLARE(void) ap_create_sb_handle(ap_sb_handle_t **new_sbh, apr_pool_t *p,
00174 int child_num, int thread_num);
00175
00176 int find_child_by_pid(apr_proc_t *pid);
00177 AP_DECLARE(int) ap_update_child_status(ap_sb_handle_t *sbh, int status, request_rec *r);
00178 AP_DECLARE(int) ap_update_child_status_from_indexes(int child_num, int thread_num,
00179 int status, request_rec *r);
00180 void ap_time_process_request(ap_sb_handle_t *sbh, int status);
00181
00182 AP_DECLARE(worker_score *) ap_get_scoreboard_worker(int x, int y);
00183 AP_DECLARE(process_score *) ap_get_scoreboard_process(int x);
00184 AP_DECLARE(global_score *) ap_get_scoreboard_global(void);
00185 AP_DECLARE(lb_score *) ap_get_scoreboard_lb(int lb_num);
00186
00187 AP_DECLARE_DATA extern scoreboard *ap_scoreboard_image;
00188 AP_DECLARE_DATA extern const char *ap_scoreboard_fname;
00189 AP_DECLARE_DATA extern int ap_extended_status;
00190
00191 AP_DECLARE_DATA extern ap_generation_t volatile ap_my_generation;
00192
00193
00201 AP_DECLARE_HOOK(int, pre_mpm, (apr_pool_t *p, ap_scoreboard_e sb_type))
00202
00207 APR_DECLARE_OPTIONAL_FN(int, ap_proxy_lb_workers,
00208 (void));
00209
00210
00211 #define START_PREQUEST 1
00212 #define STOP_PREQUEST 2
00213
00214 #ifdef __cplusplus
00215 }
00216 #endif
00217
00218 #endif