1 #ifndef _APACHEBENCH_TYPES_H_ 2 #define _APACHEBENCH_TYPES_H_ 3 4 /* ------------------- DEFINITIONS -------------------------- */ 5 6 #define CBUFFSIZE 4096 7 #define WARN_BUFFSIZE 10240 8 #define STATE_DONE 1 9 #define STATE_READY 0 10 #define RUN_PRIORITY 1 11 #define EQUAL_OPPORTUNITY 0 12 #define DEPTH_FIRST 1 13 #define BREADTH_FIRST 0 14 15 /* ------------------- STRUCTS -------------------------- */ 16 17 struct connection { 18 int fd; 19 int state; 20 int url; /* which url are we testing */ 21 int read; /* amount of bytes read */ 22 int bread; /* amount of body read */ 23 int length; /* Content-Length value used for keep-alive */ 24 char cbuff[CBUFFSIZE]; /* a buffer to store server response header */ 25 int cbx; /* offset in cbuffer */ 26 int keepalive; /* non-zero if a keep-alive request */ 27 int gotheader; /* non-zero if we have the entire header in 28 * cbuff */ 29 int thread; /* Thread number */ 30 int run; 31 32 struct timeval start_time, connect_time, before_postdata_time, sent_request_time, done_time; 33 34 char *request; /* HTTP request */ 35 char *request_headers; 36 int reqlen; 37 38 char *response_headers; /* HTTP response */ 39 char *response; 40 }; 41 42 struct data { 43 int run; /* which run */ 44 int thread; /* Thread number */ 45 int read; /* number of bytes read */ 46 int bread; /* total amount of entity body read */ 47 int ctime; /* time in ms to connect */ 48 int rtime; /* time in ms for http request */ 49 int time; /* time in ms for full req/resp interval */ 50 51 char *request; 52 char *request_headers; 53 54 char *response_headers; 55 char *response; 56 }; 57 58 struct threadval { 59 int run; /* which run */ 60 int url; /* which url are we testing */ 61 int thread; /* Thread number */ 62 }; 63 64 /* --------------------- GLOBALS ---------------------------- */ 65 66 struct global { 67 int concurrency; /* Number of multiple requests to make */ 68 int *repeats; /* Number of time to repeat for each run */ 69 int requests; /* the max of the repeats */ 70 double tlimit; /* global time limit, in seconds */ 71 struct timeval min_tlimit; /* minimum of all time limits */ 72 int *position; /* The position next run starts */ 73 74 char **hostname; /* host name */ 75 int *port; /* port numbers */ 76 char **path; /* path name */ 77 char **ctypes; /* values for Content-type: headers */ 78 double *url_tlimit; /* time limit in seconds for each url */ 79 bool *keepalive; /* whether to use Connection: Keep-Alive */ 80 81 int *posting; /* GET if ==0, POST if >0, HEAD if <0 */ 82 char **postdata, **cookie; /* datas for post and optional cookie line */ 83 SV **postsubs; /* coderefs for post */ 84 char **req_headers; /* optional arbitrary request headers to add */ 85 char ***auto_cookies; /* cookies extracted from response_headers for the run, i.e. set by http server */ 86 bool *use_auto_cookies; /* whether to use auto_cookie feature for the run */ 87 int *postlen; /* length of data to be POSTed */ 88 int *totalposted; /* total number of bytes posted, inc. headers*/ 89 90 int *good, *failed; /* number of good and bad requests */ 91 int *started, *finished, *arranged; 92 /* numbers of requests started , */ 93 /* finished or arranged for each url*/ 94 int **which_thread; /* which thread is available */ 95 struct threadval *ready_to_run_queue; 96 int head, tail, done, need_to_be_done; 97 98 int priority; 99 int *order; 100 int *buffersize; 101 int *memory; 102 int number_of_urls, number_of_runs; 103 104 char version[8]; /* to store perl module version */ 105 char warn_and_error[WARN_BUFFSIZE]; /* warn and error message returned to perl */ 106 107 int total_bytes_received; 108 struct timeval starttime, endtime; 109 110 /* one global throw-away buffer to read stuff into */ 111 char buffer[8192]; 112 113 struct connection *con; /* connection array */ 114 115 /* regression data for each request */ 116 struct data **stats; 117 118 fd_set readbits, writebits; /* bits for select */ 119 struct sockaddr_in server; /* server addr structure */ 120 }; 121 122 #endif /* !_APACHEBENCH_TYPES_H_ */ 123