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 #define SB_WORKING 0
00091 #define SB_IDLE_DIE 1
00092
00093
00094
00095
00096
00097
00098
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
00108
00109
00110
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];
00128 char request[64];
00129 char vhost[32];
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;
00137
00138
00139 apr_time_t restart_time;
00140 int lb_limit;
00141 } global_score;
00142
00143
00144 typedef struct process_score process_score;
00145 struct process_score{
00146 pid_t pid;
00147 ap_generation_t generation;
00148 ap_scoreboard_e sb_type;
00149 int quiescing;
00150
00151
00152 };
00153
00154
00155 typedef struct lb_score lb_score;
00156 struct lb_score{
00157
00158 unsigned char data[1024];
00159 };
00160
00161
00162
00163
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
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
00221 #define START_PREQUEST 1
00222 #define STOP_PREQUEST 2
00223
00224 #ifdef __cplusplus
00225 }
00226 #endif
00227
00228 #endif