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