diff options
author | Christian Grothoff <christian@grothoff.org> | 2008-04-13 03:04:38 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2008-04-13 03:04:38 +0000 |
commit | 1ea6af115589702923a795c4776135c3b1b37d06 (patch) | |
tree | 7a5d45ad9629dc523282808febf3e1b6dcc4955b | |
parent | 72c08272fdbb426830363b0903224241157deb18 (diff) | |
download | libmicrohttpd-1ea6af115589702923a795c4776135c3b1b37d06.tar.gz libmicrohttpd-1ea6af115589702923a795c4776135c3b1b37d06.zip |
large put zzufing
-rw-r--r-- | src/testzzuf/daemontest_large_put.c | 222 |
1 files changed, 103 insertions, 119 deletions
diff --git a/src/testzzuf/daemontest_large_put.c b/src/testzzuf/daemontest_large_put.c index 72399c72..ecba637b 100644 --- a/src/testzzuf/daemontest_large_put.c +++ b/src/testzzuf/daemontest_large_put.c | |||
@@ -156,6 +156,7 @@ testInternalPut () | |||
156 | NULL, NULL, &ahc_echo, &done_flag, MHD_OPTION_END); | 156 | NULL, NULL, &ahc_echo, &done_flag, MHD_OPTION_END); |
157 | if (d == NULL) | 157 | if (d == NULL) |
158 | return 1; | 158 | return 1; |
159 | zzuf_socat_start (); | ||
159 | for (i = 0; i < LOOP_COUNT; i++) | 160 | for (i = 0; i < LOOP_COUNT; i++) |
160 | { | 161 | { |
161 | fprintf (stderr, "."); | 162 | fprintf (stderr, "."); |
@@ -195,57 +196,50 @@ testMultithreadedPut () | |||
195 | struct CBC cbc; | 196 | struct CBC cbc; |
196 | unsigned int pos = 0; | 197 | unsigned int pos = 0; |
197 | int done_flag = 0; | 198 | int done_flag = 0; |
198 | CURLcode errornum; | ||
199 | char buf[2048]; | 199 | char buf[2048]; |
200 | int i; | ||
200 | 201 | ||
201 | cbc.buf = buf; | 202 | cbc.buf = buf; |
202 | cbc.size = 2048; | 203 | cbc.size = 2048; |
203 | cbc.pos = 0; | 204 | cbc.pos = 0; |
204 | d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_DEBUG, | 205 | d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_DEBUG, |
205 | 1081, | 206 | 11080, |
206 | NULL, NULL, &ahc_echo, &done_flag, MHD_OPTION_END); | 207 | NULL, NULL, &ahc_echo, &done_flag, MHD_OPTION_END); |
207 | if (d == NULL) | 208 | if (d == NULL) |
208 | { | 209 | { |
209 | free (cbc.buf); | 210 | free (cbc.buf); |
210 | return 16; | 211 | return 16; |
211 | } | 212 | } |
212 | c = curl_easy_init (); | 213 | zzuf_socat_start (); |
213 | curl_easy_setopt (c, CURLOPT_URL, "http://localhost:1081/hello_world"); | 214 | for (i = 0; i < LOOP_COUNT; i++) |
214 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); | ||
215 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); | ||
216 | curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer); | ||
217 | curl_easy_setopt (c, CURLOPT_READDATA, &pos); | ||
218 | curl_easy_setopt (c, CURLOPT_UPLOAD, 1L); | ||
219 | curl_easy_setopt (c, CURLOPT_INFILESIZE, (long) PUT_SIZE); | ||
220 | curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); | ||
221 | curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); | ||
222 | if (oneone) | ||
223 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); | ||
224 | else | ||
225 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); | ||
226 | curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 15L); | ||
227 | // NOTE: use of CONNECTTIMEOUT without also | ||
228 | // setting NOSIGNAL results in really weird | ||
229 | // crashes on my system! | ||
230 | curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1); | ||
231 | if (CURLE_OK != (errornum = curl_easy_perform (c))) | ||
232 | { | 215 | { |
233 | fprintf (stderr, | 216 | fprintf (stderr, "."); |
234 | "curl_easy_perform failed: `%s'\n", | 217 | |
235 | curl_easy_strerror (errornum)); | 218 | c = curl_easy_init (); |
219 | curl_easy_setopt (c, CURLOPT_URL, "http://localhost:11081/hello_world"); | ||
220 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); | ||
221 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); | ||
222 | curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer); | ||
223 | curl_easy_setopt (c, CURLOPT_READDATA, &pos); | ||
224 | curl_easy_setopt (c, CURLOPT_UPLOAD, 1L); | ||
225 | curl_easy_setopt (c, CURLOPT_INFILESIZE, (long) PUT_SIZE); | ||
226 | curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); | ||
227 | curl_easy_setopt (c, CURLOPT_TIMEOUT_MS, CURL_TIMEOUT); | ||
228 | if (oneone) | ||
229 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); | ||
230 | else | ||
231 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); | ||
232 | curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT_MS, CURL_TIMEOUT); | ||
233 | // NOTE: use of CONNECTTIMEOUT without also | ||
234 | // setting NOSIGNAL results in really weird | ||
235 | // crashes on my system! | ||
236 | curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1); | ||
237 | curl_easy_perform (c); | ||
236 | curl_easy_cleanup (c); | 238 | curl_easy_cleanup (c); |
237 | MHD_stop_daemon (d); | ||
238 | return 32; | ||
239 | } | 239 | } |
240 | curl_easy_cleanup (c); | 240 | fprintf (stderr, "\n"); |
241 | zzuf_socat_stop (); | ||
241 | MHD_stop_daemon (d); | 242 | MHD_stop_daemon (d); |
242 | if (cbc.pos != strlen ("/hello_world")) | ||
243 | { | ||
244 | fprintf (stderr, "Got invalid response `%.*s'\n", cbc.pos, cbc.buf); | ||
245 | return 64; | ||
246 | } | ||
247 | if (0 != strncmp ("/hello_world", cbc.buf, strlen ("/hello_world"))) | ||
248 | return 128; | ||
249 | return 0; | 243 | return 0; |
250 | } | 244 | } |
251 | 245 | ||
@@ -263,45 +257,24 @@ testExternalPut () | |||
263 | fd_set es; | 257 | fd_set es; |
264 | int max; | 258 | int max; |
265 | int running; | 259 | int running; |
266 | struct CURLMsg *msg; | ||
267 | time_t start; | 260 | time_t start; |
268 | struct timeval tv; | 261 | struct timeval tv; |
269 | unsigned int pos = 0; | 262 | unsigned int pos = 0; |
270 | int done_flag = 0; | 263 | int done_flag = 0; |
271 | char buf[2048]; | 264 | char buf[2048]; |
265 | int i; | ||
272 | 266 | ||
273 | cbc.buf = buf; | 267 | cbc.buf = buf; |
274 | cbc.size = 2048; | 268 | cbc.size = 2048; |
275 | cbc.pos = 0; | 269 | cbc.pos = 0; |
276 | multi = NULL; | 270 | multi = NULL; |
277 | d = MHD_start_daemon (MHD_USE_DEBUG, | 271 | d = MHD_start_daemon (MHD_NO_FLAG | MHD_USE_DEBUG, |
278 | 1082, | 272 | 11080, |
279 | NULL, NULL, &ahc_echo, &done_flag, | 273 | NULL, NULL, &ahc_echo, &done_flag, |
280 | MHD_OPTION_CONNECTION_MEMORY_LIMIT, | 274 | MHD_OPTION_CONNECTION_MEMORY_LIMIT, |
281 | PUT_SIZE * 4, MHD_OPTION_END); | 275 | PUT_SIZE * 4, MHD_OPTION_END); |
282 | if (d == NULL) | 276 | if (d == NULL) |
283 | return 256; | 277 | return 256; |
284 | c = curl_easy_init (); | ||
285 | curl_easy_setopt (c, CURLOPT_URL, "http://localhost:1082/hello_world"); | ||
286 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); | ||
287 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); | ||
288 | curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer); | ||
289 | curl_easy_setopt (c, CURLOPT_READDATA, &pos); | ||
290 | curl_easy_setopt (c, CURLOPT_UPLOAD, 1L); | ||
291 | curl_easy_setopt (c, CURLOPT_INFILESIZE, (long) PUT_SIZE); | ||
292 | curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); | ||
293 | curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); | ||
294 | if (oneone) | ||
295 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); | ||
296 | else | ||
297 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); | ||
298 | curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 15L); | ||
299 | // NOTE: use of CONNECTTIMEOUT without also | ||
300 | // setting NOSIGNAL results in really weird | ||
301 | // crashes on my system! | ||
302 | curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1); | ||
303 | |||
304 | |||
305 | multi = curl_multi_init (); | 278 | multi = curl_multi_init (); |
306 | if (multi == NULL) | 279 | if (multi == NULL) |
307 | { | 280 | { |
@@ -309,78 +282,92 @@ testExternalPut () | |||
309 | MHD_stop_daemon (d); | 282 | MHD_stop_daemon (d); |
310 | return 512; | 283 | return 512; |
311 | } | 284 | } |
312 | mret = curl_multi_add_handle (multi, c); | 285 | zzuf_socat_start (); |
313 | if (mret != CURLM_OK) | 286 | for (i = 0; i < LOOP_COUNT; i++) |
314 | { | ||
315 | curl_multi_cleanup (multi); | ||
316 | curl_easy_cleanup (c); | ||
317 | MHD_stop_daemon (d); | ||
318 | return 1024; | ||
319 | } | ||
320 | start = time (NULL); | ||
321 | while ((time (NULL) - start < 5) && (multi != NULL)) | ||
322 | { | 287 | { |
323 | max = 0; | 288 | fprintf (stderr, "."); |
324 | FD_ZERO (&rs); | 289 | |
325 | FD_ZERO (&ws); | 290 | c = curl_easy_init (); |
326 | FD_ZERO (&es); | 291 | curl_easy_setopt (c, CURLOPT_URL, "http://localhost:11081/hello_world"); |
327 | curl_multi_perform (multi, &running); | 292 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); |
328 | mret = curl_multi_fdset (multi, &rs, &ws, &es, &max); | 293 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); |
294 | curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer); | ||
295 | curl_easy_setopt (c, CURLOPT_READDATA, &pos); | ||
296 | curl_easy_setopt (c, CURLOPT_UPLOAD, 1L); | ||
297 | curl_easy_setopt (c, CURLOPT_INFILESIZE, (long) PUT_SIZE); | ||
298 | curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); | ||
299 | curl_easy_setopt (c, CURLOPT_TIMEOUT_MS, CURL_TIMEOUT); | ||
300 | if (oneone) | ||
301 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); | ||
302 | else | ||
303 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); | ||
304 | curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT_MS, CURL_TIMEOUT); | ||
305 | // NOTE: use of CONNECTTIMEOUT without also | ||
306 | // setting NOSIGNAL results in really weird | ||
307 | // crashes on my system! | ||
308 | curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1); | ||
309 | |||
310 | |||
311 | |||
312 | mret = curl_multi_add_handle (multi, c); | ||
329 | if (mret != CURLM_OK) | 313 | if (mret != CURLM_OK) |
330 | { | 314 | { |
331 | curl_multi_remove_handle (multi, c); | ||
332 | curl_multi_cleanup (multi); | ||
333 | curl_easy_cleanup (c); | ||
334 | MHD_stop_daemon (d); | ||
335 | return 2048; | ||
336 | } | ||
337 | if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &max)) | ||
338 | { | ||
339 | curl_multi_remove_handle (multi, c); | ||
340 | curl_multi_cleanup (multi); | 315 | curl_multi_cleanup (multi); |
341 | curl_easy_cleanup (c); | 316 | curl_easy_cleanup (c); |
317 | zzuf_socat_stop (); | ||
342 | MHD_stop_daemon (d); | 318 | MHD_stop_daemon (d); |
343 | return 4096; | 319 | return 1024; |
344 | } | 320 | } |
345 | tv.tv_sec = 0; | 321 | start = time (NULL); |
346 | tv.tv_usec = 1000; | 322 | while ((time (NULL) - start < 5) && (multi != NULL)) |
347 | select (max + 1, &rs, &ws, &es, &tv); | ||
348 | curl_multi_perform (multi, &running); | ||
349 | if (running == 0) | ||
350 | { | 323 | { |
351 | msg = curl_multi_info_read (multi, &running); | 324 | max = 0; |
352 | if (msg == NULL) | 325 | FD_ZERO (&rs); |
353 | break; | 326 | FD_ZERO (&ws); |
354 | if (msg->msg == CURLMSG_DONE) | 327 | FD_ZERO (&es); |
328 | curl_multi_perform (multi, &running); | ||
329 | mret = curl_multi_fdset (multi, &rs, &ws, &es, &max); | ||
330 | if (mret != CURLM_OK) | ||
355 | { | 331 | { |
356 | if (msg->data.result != CURLE_OK) | ||
357 | printf ("%s failed at %s:%d: `%s'\n", | ||
358 | "curl_multi_perform", | ||
359 | __FILE__, | ||
360 | __LINE__, curl_easy_strerror (msg->data.result)); | ||
361 | curl_multi_remove_handle (multi, c); | 332 | curl_multi_remove_handle (multi, c); |
362 | curl_multi_cleanup (multi); | 333 | curl_multi_cleanup (multi); |
363 | curl_easy_cleanup (c); | 334 | curl_easy_cleanup (c); |
335 | zzuf_socat_stop (); | ||
336 | MHD_stop_daemon (d); | ||
337 | return 2048; | ||
338 | } | ||
339 | if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &max)) | ||
340 | { | ||
341 | curl_multi_remove_handle (multi, c); | ||
342 | curl_multi_cleanup (multi); | ||
343 | curl_easy_cleanup (c); | ||
344 | zzuf_socat_stop (); | ||
345 | MHD_stop_daemon (d); | ||
346 | return 4096; | ||
347 | } | ||
348 | tv.tv_sec = 0; | ||
349 | tv.tv_usec = 1000; | ||
350 | select (max + 1, &rs, &ws, &es, &tv); | ||
351 | curl_multi_perform (multi, &running); | ||
352 | if (running == 0) | ||
353 | { | ||
354 | curl_multi_info_read (multi, &running); | ||
355 | curl_multi_remove_handle (multi, c); | ||
356 | curl_easy_cleanup (c); | ||
364 | c = NULL; | 357 | c = NULL; |
365 | multi = NULL; | ||
366 | } | 358 | } |
359 | MHD_run (d); | ||
360 | } | ||
361 | if (c != NULL) | ||
362 | { | ||
363 | curl_multi_remove_handle (multi, c); | ||
364 | curl_easy_cleanup (c); | ||
367 | } | 365 | } |
368 | MHD_run (d); | ||
369 | } | ||
370 | if (multi != NULL) | ||
371 | { | ||
372 | curl_multi_remove_handle (multi, c); | ||
373 | curl_easy_cleanup (c); | ||
374 | curl_multi_cleanup (multi); | ||
375 | } | 366 | } |
367 | fprintf (stderr, "\n"); | ||
368 | zzuf_socat_stop (); | ||
369 | curl_multi_cleanup (multi); | ||
376 | MHD_stop_daemon (d); | 370 | MHD_stop_daemon (d); |
377 | if (cbc.pos != strlen ("/hello_world")) | ||
378 | { | ||
379 | fprintf (stderr, "Got invalid response `%.*s'\n", cbc.pos, cbc.buf); | ||
380 | return 8192; | ||
381 | } | ||
382 | if (0 != strncmp ("/hello_world", cbc.buf, strlen ("/hello_world"))) | ||
383 | return 16384; | ||
384 | return 0; | 371 | return 0; |
385 | } | 372 | } |
386 | 373 | ||
@@ -396,11 +383,8 @@ main (int argc, char *const *argv) | |||
396 | return 2; | 383 | return 2; |
397 | put_buffer = malloc (PUT_SIZE); | 384 | put_buffer = malloc (PUT_SIZE); |
398 | memset (put_buffer, 1, PUT_SIZE); | 385 | memset (put_buffer, 1, PUT_SIZE); |
399 | if (0) | 386 | errorCount += testInternalPut (); |
400 | { | 387 | errorCount += testMultithreadedPut (); |
401 | errorCount += testInternalPut (); | ||
402 | errorCount += testMultithreadedPut (); | ||
403 | } | ||
404 | errorCount += testExternalPut (); | 388 | errorCount += testExternalPut (); |
405 | free (put_buffer); | 389 | free (put_buffer); |
406 | if (errorCount != 0) | 390 | if (errorCount != 0) |