1 2 /* $Id: fpm_status.h 312263 2011-06-18 17:46:16Z felipe $ */ 3 /* (c) 2009 Jerome Loyet */ 4 5 #ifndef FPM_SCOREBOARD_H 6 #define FPM_SCOREBOARD_H 1 7 8 #include <sys/time.h> 9 #ifdef HAVE_TIMES 10 #include <sys/times.h> 11 #endif 12 13 #include "fpm_request.h" 14 #include "fpm_worker_pool.h" 15 #include "fpm_atomic.h" 16 17 #define FPM_SCOREBOARD_ACTION_SET 0 18 #define FPM_SCOREBOARD_ACTION_INC 1 19 20 struct fpm_scoreboard_proc_s { 21 union { 22 atomic_t lock; 23 char dummy[16]; 24 }; 25 int used; 26 time_t start_epoch; 27 pid_t pid; 28 unsigned long requests; 29 enum fpm_request_stage_e request_stage; 30 struct timeval accepted; 31 struct timeval duration; 32 time_t accepted_epoch; 33 struct timeval tv; 34 char request_uri[128]; 35 char query_string[512]; 36 char request_method[16]; 37 size_t content_length; /* used with POST only */ 38 char script_filename[256]; 39 char auth_user[32]; 40 #ifdef HAVE_TIMES 41 struct tms cpu_accepted; 42 struct timeval cpu_duration; 43 struct tms last_request_cpu; 44 struct timeval last_request_cpu_duration; 45 #endif 46 size_t memory; 47 }; 48 49 struct fpm_scoreboard_s { 50 union { 51 atomic_t lock; 52 char dummy[16]; 53 }; 54 char pool[32]; 55 int pm; 56 time_t start_epoch; 57 int idle; 58 int active; 59 int active_max; 60 unsigned long int requests; 61 unsigned int max_children_reached; 62 int lq; 63 int lq_max; 64 unsigned int lq_len; 65 unsigned int nprocs; 66 int free_proc; 67 unsigned long int slow_rq; 68 struct fpm_scoreboard_proc_s *procs[]; 69 }; 70 71 int fpm_scoreboard_init_main(); 72 int fpm_scoreboard_init_child(struct fpm_worker_pool_s *wp); 73 74 void fpm_scoreboard_update(int idle, int active, int lq, int lq_len, int requests, int max_children_reached, int slow_rq, int action, struct fpm_scoreboard_s *scoreboard); 75 struct fpm_scoreboard_s *fpm_scoreboard_get(); 76 struct fpm_scoreboard_proc_s *fpm_scoreboard_proc_get(struct fpm_scoreboard_s *scoreboard, int child_index); 77 78 struct fpm_scoreboard_s *fpm_scoreboard_acquire(struct fpm_scoreboard_s *scoreboard, int nohang); 79 void fpm_scoreboard_release(struct fpm_scoreboard_s *scoreboard); 80 struct fpm_scoreboard_proc_s *fpm_scoreboard_proc_acquire(struct fpm_scoreboard_s *scoreboard, int child_index, int nohang); 81 void fpm_scoreboard_proc_release(struct fpm_scoreboard_proc_s *proc); 82 83 void fpm_scoreboard_free(struct fpm_scoreboard_s *scoreboard); 84 85 void fpm_scoreboard_child_use(struct fpm_scoreboard_s *scoreboard, int child_index, pid_t pid); 86 87 void fpm_scoreboard_proc_free(struct fpm_scoreboard_s *scoreboard, int child_index); 88 int fpm_scoreboard_proc_alloc(struct fpm_scoreboard_s *scoreboard, int *child_index); 89 90 #ifdef HAVE_TIMES 91 float fpm_scoreboard_get_tick(); 92 #endif 93 94 #endif 95