Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Test the response length. Now it counts an error whenever a response

is 10% bigger or smaller than the first one.


git-svn-id: svn://cherokee-project.com/benchmark@3541 5dc97367-97f1-0310-9951-d761b3857238
  • Loading branch information...
commit ffd831379ecbceac7dc2629117d1403e319ea5a7 1 parent 7419e64
Alvaro Lopez Ortega alobbs authored

Showing 1 changed file with 33 additions and 8 deletions. Show diff stats Hide diff stats

  1. +33 8 main.c
41 main.c
@@ -88,6 +88,8 @@ static int thread_num = THREAD_NUM_DEFAULT;
88 88 static long request_num = REQUEST_NUM_DEFAULT;
89 89 static int verbose = 0;
90 90 static int finished = 0;
  91 +static int resp_check = 1;
  92 +static int resp_size = -1;
91 93 static volatile long request_done = 0;
92 94 static volatile long request_fails = 0;
93 95 static volatile time_msec_t time_start = 0;
@@ -147,32 +149,48 @@ print_error_codes (void)
147 149 }
148 150
149 151
150   -static void
151   -count_response (long http_code)
  152 +static int
  153 +count_response (long http_code,
  154 + long downloaded)
152 155 {
153 156 int i;
154   -
  157 +
  158 + /* Check downloaded */
  159 + if (resp_check) {
  160 + if (resp_size == -1) {
  161 + resp_size = downloaded;
  162 + } else {
  163 + if ((downloaded < resp_size * 0.90) ||
  164 + (downloaded > resp_size * 1.10))
  165 + {
  166 + return 1;
  167 + }
  168 + }
  169 + }
  170 +
  171 + /* Finished? */
155 172 if (request_done >= request_num) {
156 173 finished = 1;
157   - return;
  174 + return 0;
158 175 }
159   -
160 176 request_done++;
161 177
  178 + /* HTTP code */
162 179 for (i=0; i<RESPONSES_COUNT_LEN; i++) {
163 180 if (responses[i].http_code == 0) {
164 181 responses[i].http_code = http_code;
165 182 responses[i].count = 1;
166   - return;
  183 + return 0;
167 184
168 185 } else if (responses[i].http_code == http_code) {
169 186 responses[i].count++;
170   - return;
  187 + return 0;
171 188 }
172 189 }
173 190
174 191 finished = 1;
175 192 fprintf (stderr, "FATAL ERROR: Run out of http_error space\n");
  193 + return 1;
176 194 }
177 195
178 196 static size_t
@@ -205,6 +223,7 @@ thread_routine (void *me)
205 223 {
206 224 int re;
207 225 long http_code;
  226 + long downloaded;
208 227 int is_error = 0;
209 228 cb_thread_t *thread = (cb_thread_t *)me;
210 229 cb_url_t *url = (cb_url_t *)urls.next;
@@ -244,7 +263,13 @@ thread_routine (void *me)
244 263 switch (re) {
245 264 case CURLE_OK:
246 265 curl_easy_getinfo (thread->curl, CURLINFO_RESPONSE_CODE, &http_code);
247   - count_response (http_code);
  266 + curl_easy_getinfo (thread->curl, CURLINFO_SIZE_DOWNLOAD, &downloaded);
  267 +
  268 + re = count_response (http_code, downloaded);
  269 + if (re != 0) {
  270 + is_error = 1;
  271 + request_fails++;
  272 + }
248 273 break;
249 274
250 275 case CURLE_COULDNT_RESOLVE_HOST:

0 comments on commit ffd8313

Please sign in to comment.
Something went wrong with that request. Please try again.