Back to index

php5  5.3.10
fpm_scoreboard.h
Go to the documentation of this file.
00001 
00002        /* $Id: fpm_status.h 312263 2011-06-18 17:46:16Z felipe $ */
00003        /* (c) 2009 Jerome Loyet */
00004 
00005 #ifndef FPM_SCOREBOARD_H
00006 #define FPM_SCOREBOARD_H 1
00007 
00008 #include <sys/time.h>
00009 #ifdef HAVE_TIMES
00010 #include <sys/times.h>
00011 #endif
00012 
00013 #include "fpm_request.h"
00014 #include "fpm_worker_pool.h"
00015 #include "fpm_atomic.h"
00016 
00017 #define FPM_SCOREBOARD_ACTION_SET 0
00018 #define FPM_SCOREBOARD_ACTION_INC 1
00019 
00020 struct fpm_scoreboard_proc_s {
00021        union {
00022               atomic_t lock;
00023               char dummy[16];
00024        };
00025        int used;
00026        time_t start_epoch;
00027        pid_t pid;
00028        unsigned long requests;
00029        enum fpm_request_stage_e request_stage;
00030        struct timeval accepted;
00031        struct timeval duration;
00032        time_t accepted_epoch;
00033        struct timeval tv;
00034        char request_uri[128];
00035        char query_string[512];
00036        char request_method[16];
00037        size_t content_length; /* used with POST only */
00038        char script_filename[256];
00039        char auth_user[32];
00040 #ifdef HAVE_TIMES
00041        struct tms cpu_accepted;
00042        struct timeval cpu_duration;
00043        struct tms last_request_cpu;
00044        struct timeval last_request_cpu_duration;
00045 #endif
00046        size_t memory;
00047 };
00048 
00049 struct fpm_scoreboard_s {
00050        union {
00051               atomic_t lock;
00052               char dummy[16];
00053        };
00054        char pool[32];
00055        int pm;
00056        time_t start_epoch;
00057        int idle;
00058        int active;
00059        int active_max;
00060        unsigned long int requests;
00061        unsigned int max_children_reached;
00062        int lq;
00063        int lq_max;
00064        unsigned int lq_len;
00065        unsigned int nprocs;
00066        int free_proc;
00067        struct fpm_scoreboard_proc_s *procs[];
00068 };
00069 
00070 int fpm_scoreboard_init_main();
00071 int fpm_scoreboard_init_child(struct fpm_worker_pool_s *wp);
00072 
00073 void fpm_scoreboard_update(int idle, int active, int lq, int lq_len, int requests, int max_children_reached, int action, struct fpm_scoreboard_s *scoreboard);
00074 struct fpm_scoreboard_s *fpm_scoreboard_get();
00075 struct fpm_scoreboard_proc_s *fpm_scoreboard_proc_get(struct fpm_scoreboard_s *scoreboard, int child_index);
00076 
00077 struct fpm_scoreboard_s *fpm_scoreboard_acquire(struct fpm_scoreboard_s *scoreboard, int nohang);
00078 void fpm_scoreboard_release(struct fpm_scoreboard_s *scoreboard);
00079 struct fpm_scoreboard_proc_s *fpm_scoreboard_proc_acquire(struct fpm_scoreboard_s *scoreboard, int child_index, int nohang);
00080 void fpm_scoreboard_proc_release(struct fpm_scoreboard_proc_s *proc);
00081 
00082 void fpm_scoreboard_free(struct fpm_scoreboard_s *scoreboard);
00083 
00084 void fpm_scoreboard_child_use(struct fpm_scoreboard_s *scoreboard, int child_index, pid_t pid);
00085 
00086 void fpm_scoreboard_proc_free(struct fpm_scoreboard_s *scoreboard, int child_index);
00087 int fpm_scoreboard_proc_alloc(struct fpm_scoreboard_s *scoreboard, int *child_index);
00088 
00089 #ifdef HAVE_TIMES
00090 float fpm_scoreboard_get_tick();
00091 #endif
00092 
00093 #endif