diff options
Diffstat (limited to 'src/testzzuf/test_put_large.c')
-rw-r--r-- | src/testzzuf/test_put_large.c | 324 |
1 files changed, 163 insertions, 161 deletions
diff --git a/src/testzzuf/test_put_large.c b/src/testzzuf/test_put_large.c index 815ce77d..1186f583 100644 --- a/src/testzzuf/test_put_large.c +++ b/src/testzzuf/test_put_large.c | |||
@@ -94,35 +94,35 @@ ahc_echo (void *cls, | |||
94 | int *done = cls; | 94 | int *done = cls; |
95 | struct MHD_Response *response; | 95 | struct MHD_Response *response; |
96 | int ret; | 96 | int ret; |
97 | (void)version;(void)unused; /* Unused. Silent compiler warning. */ | 97 | (void) version; (void) unused; /* Unused. Silent compiler warning. */ |
98 | 98 | ||
99 | if (0 != strcmp ("PUT", method)) | 99 | if (0 != strcmp ("PUT", method)) |
100 | return MHD_NO; /* unexpected method */ | 100 | return MHD_NO; /* unexpected method */ |
101 | if ((*done) == 0) | 101 | if ((*done) == 0) |
102 | { | ||
103 | if (*upload_data_size != PUT_SIZE) | ||
102 | { | 104 | { |
103 | if (*upload_data_size != PUT_SIZE) | ||
104 | { | ||
105 | #if 0 | 105 | #if 0 |
106 | fprintf (stderr, | 106 | fprintf (stderr, |
107 | "Waiting for more data (%u/%u)...\n", | 107 | "Waiting for more data (%u/%u)...\n", |
108 | *upload_data_size, PUT_SIZE); | 108 | *upload_data_size, PUT_SIZE); |
109 | #endif | 109 | #endif |
110 | return MHD_YES; /* not yet ready */ | 110 | return MHD_YES; /* not yet ready */ |
111 | } | ||
112 | if (0 == memcmp (upload_data, put_buffer, PUT_SIZE)) | ||
113 | { | ||
114 | *upload_data_size = 0; | ||
115 | } | ||
116 | else | ||
117 | { | ||
118 | return MHD_NO; | ||
119 | } | ||
120 | *done = 1; | ||
121 | return MHD_YES; | ||
122 | } | 111 | } |
112 | if (0 == memcmp (upload_data, put_buffer, PUT_SIZE)) | ||
113 | { | ||
114 | *upload_data_size = 0; | ||
115 | } | ||
116 | else | ||
117 | { | ||
118 | return MHD_NO; | ||
119 | } | ||
120 | *done = 1; | ||
121 | return MHD_YES; | ||
122 | } | ||
123 | response = MHD_create_response_from_buffer (strlen (url), | 123 | response = MHD_create_response_from_buffer (strlen (url), |
124 | (void *) url, | 124 | (void *) url, |
125 | MHD_RESPMEM_MUST_COPY); | 125 | MHD_RESPMEM_MUST_COPY); |
126 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); | 126 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); |
127 | MHD_destroy_response (response); | 127 | MHD_destroy_response (response); |
128 | return ret; | 128 | return ret; |
@@ -143,38 +143,39 @@ testInternalPut () | |||
143 | cbc.buf = buf; | 143 | cbc.buf = buf; |
144 | cbc.size = 2048; | 144 | cbc.size = 2048; |
145 | cbc.pos = 0; | 145 | cbc.pos = 0; |
146 | d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD /* | MHD_USE_ERROR_LOG */ , | 146 | d = MHD_start_daemon ( |
147 | 11080, | 147 | MHD_USE_INTERNAL_POLLING_THREAD /* | MHD_USE_ERROR_LOG */, |
148 | NULL, NULL, &ahc_echo, &done_flag, MHD_OPTION_END); | 148 | 11080, |
149 | NULL, NULL, &ahc_echo, &done_flag, MHD_OPTION_END); | ||
149 | if (d == NULL) | 150 | if (d == NULL) |
150 | return 1; | 151 | return 1; |
151 | zzuf_socat_start (); | 152 | zzuf_socat_start (); |
152 | for (i = 0; i < LOOP_COUNT; i++) | 153 | for (i = 0; i < LOOP_COUNT; i++) |
153 | { | 154 | { |
154 | fprintf (stderr, "."); | 155 | fprintf (stderr, "."); |
155 | 156 | ||
156 | c = curl_easy_init (); | 157 | c = curl_easy_init (); |
157 | curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1:11081/hello_world"); | 158 | curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1:11081/hello_world"); |
158 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); | 159 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); |
159 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); | 160 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); |
160 | curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer); | 161 | curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer); |
161 | curl_easy_setopt (c, CURLOPT_READDATA, &pos); | 162 | curl_easy_setopt (c, CURLOPT_READDATA, &pos); |
162 | curl_easy_setopt (c, CURLOPT_UPLOAD, 1L); | 163 | curl_easy_setopt (c, CURLOPT_UPLOAD, 1L); |
163 | curl_easy_setopt (c, CURLOPT_INFILESIZE, (long) PUT_SIZE); | 164 | curl_easy_setopt (c, CURLOPT_INFILESIZE, (long) PUT_SIZE); |
164 | curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); | 165 | curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); |
165 | curl_easy_setopt (c, CURLOPT_TIMEOUT_MS, CURL_TIMEOUT); | 166 | curl_easy_setopt (c, CURLOPT_TIMEOUT_MS, CURL_TIMEOUT); |
166 | if (oneone) | 167 | if (oneone) |
167 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); | 168 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); |
168 | else | 169 | else |
169 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); | 170 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); |
170 | curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT_MS, CURL_TIMEOUT); | 171 | curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT_MS, CURL_TIMEOUT); |
171 | /* NOTE: use of CONNECTTIMEOUT without also | 172 | /* NOTE: use of CONNECTTIMEOUT without also |
172 | * setting NOSIGNAL results in really weird | 173 | * setting NOSIGNAL results in really weird |
173 | * crashes on my system! */ | 174 | * crashes on my system! */ |
174 | curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); | 175 | curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); |
175 | curl_easy_perform (c); | 176 | curl_easy_perform (c); |
176 | curl_easy_cleanup (c); | 177 | curl_easy_cleanup (c); |
177 | } | 178 | } |
178 | fprintf (stderr, "\n"); | 179 | fprintf (stderr, "\n"); |
179 | zzuf_socat_stop (); | 180 | zzuf_socat_stop (); |
180 | MHD_stop_daemon (d); | 181 | MHD_stop_daemon (d); |
@@ -195,38 +196,39 @@ testMultithreadedPut () | |||
195 | cbc.buf = buf; | 196 | cbc.buf = buf; |
196 | cbc.size = 2048; | 197 | cbc.size = 2048; |
197 | cbc.pos = 0; | 198 | cbc.pos = 0; |
198 | d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD /* | MHD_USE_ERROR_LOG */ , | 199 | d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION |
200 | | MHD_USE_INTERNAL_POLLING_THREAD /* | MHD_USE_ERROR_LOG */, | ||
199 | 11080, | 201 | 11080, |
200 | NULL, NULL, &ahc_echo, &done_flag, MHD_OPTION_END); | 202 | NULL, NULL, &ahc_echo, &done_flag, MHD_OPTION_END); |
201 | if (d == NULL) | 203 | if (d == NULL) |
202 | return 16; | 204 | return 16; |
203 | zzuf_socat_start (); | 205 | zzuf_socat_start (); |
204 | for (i = 0; i < LOOP_COUNT; i++) | 206 | for (i = 0; i < LOOP_COUNT; i++) |
205 | { | 207 | { |
206 | fprintf (stderr, "."); | 208 | fprintf (stderr, "."); |
207 | 209 | ||
208 | c = curl_easy_init (); | 210 | c = curl_easy_init (); |
209 | curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1:11081/hello_world"); | 211 | curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1:11081/hello_world"); |
210 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); | 212 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); |
211 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); | 213 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); |
212 | curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer); | 214 | curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer); |
213 | curl_easy_setopt (c, CURLOPT_READDATA, &pos); | 215 | curl_easy_setopt (c, CURLOPT_READDATA, &pos); |
214 | curl_easy_setopt (c, CURLOPT_UPLOAD, 1L); | 216 | curl_easy_setopt (c, CURLOPT_UPLOAD, 1L); |
215 | curl_easy_setopt (c, CURLOPT_INFILESIZE, (long) PUT_SIZE); | 217 | curl_easy_setopt (c, CURLOPT_INFILESIZE, (long) PUT_SIZE); |
216 | curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); | 218 | curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); |
217 | curl_easy_setopt (c, CURLOPT_TIMEOUT_MS, CURL_TIMEOUT); | 219 | curl_easy_setopt (c, CURLOPT_TIMEOUT_MS, CURL_TIMEOUT); |
218 | if (oneone) | 220 | if (oneone) |
219 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); | 221 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); |
220 | else | 222 | else |
221 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); | 223 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); |
222 | curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT_MS, CURL_TIMEOUT); | 224 | curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT_MS, CURL_TIMEOUT); |
223 | /* NOTE: use of CONNECTTIMEOUT without also | 225 | /* NOTE: use of CONNECTTIMEOUT without also |
224 | * setting NOSIGNAL results in really weird | 226 | * setting NOSIGNAL results in really weird |
225 | * crashes on my system! */ | 227 | * crashes on my system! */ |
226 | curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); | 228 | curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); |
227 | curl_easy_perform (c); | 229 | curl_easy_perform (c); |
228 | curl_easy_cleanup (c); | 230 | curl_easy_cleanup (c); |
229 | } | 231 | } |
230 | fprintf (stderr, "\n"); | 232 | fprintf (stderr, "\n"); |
231 | zzuf_socat_stop (); | 233 | zzuf_socat_stop (); |
232 | MHD_stop_daemon (d); | 234 | MHD_stop_daemon (d); |
@@ -267,92 +269,92 @@ testExternalPut () | |||
267 | return 256; | 269 | return 256; |
268 | multi = curl_multi_init (); | 270 | multi = curl_multi_init (); |
269 | if (multi == NULL) | 271 | if (multi == NULL) |
272 | { | ||
273 | MHD_stop_daemon (d); | ||
274 | return 512; | ||
275 | } | ||
276 | zzuf_socat_start (); | ||
277 | for (i = 0; i < LOOP_COUNT; i++) | ||
278 | { | ||
279 | fprintf (stderr, "."); | ||
280 | |||
281 | c = curl_easy_init (); | ||
282 | curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1:11081/hello_world"); | ||
283 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); | ||
284 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); | ||
285 | curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer); | ||
286 | curl_easy_setopt (c, CURLOPT_READDATA, &pos); | ||
287 | curl_easy_setopt (c, CURLOPT_UPLOAD, 1L); | ||
288 | curl_easy_setopt (c, CURLOPT_INFILESIZE, (long) PUT_SIZE); | ||
289 | curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); | ||
290 | curl_easy_setopt (c, CURLOPT_TIMEOUT_MS, CURL_TIMEOUT); | ||
291 | if (oneone) | ||
292 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); | ||
293 | else | ||
294 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); | ||
295 | curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT_MS, CURL_TIMEOUT); | ||
296 | /* NOTE: use of CONNECTTIMEOUT without also | ||
297 | * setting NOSIGNAL results in really weird | ||
298 | * crashes on my system! */ | ||
299 | curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); | ||
300 | |||
301 | |||
302 | |||
303 | mret = curl_multi_add_handle (multi, c); | ||
304 | if (mret != CURLM_OK) | ||
270 | { | 305 | { |
306 | curl_multi_cleanup (multi); | ||
307 | curl_easy_cleanup (c); | ||
308 | zzuf_socat_stop (); | ||
271 | MHD_stop_daemon (d); | 309 | MHD_stop_daemon (d); |
272 | return 512; | 310 | return 1024; |
273 | } | 311 | } |
274 | zzuf_socat_start (); | 312 | start = time (NULL); |
275 | for (i = 0; i < LOOP_COUNT; i++) | 313 | while ((time (NULL) - start < 5) && (c != NULL)) |
276 | { | 314 | { |
277 | fprintf (stderr, "."); | 315 | max = 0; |
278 | 316 | FD_ZERO (&rs); | |
279 | c = curl_easy_init (); | 317 | FD_ZERO (&ws); |
280 | curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1:11081/hello_world"); | 318 | FD_ZERO (&es); |
281 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); | 319 | curl_multi_perform (multi, &running); |
282 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); | 320 | mret = curl_multi_fdset (multi, &rs, &ws, &es, &max); |
283 | curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer); | ||
284 | curl_easy_setopt (c, CURLOPT_READDATA, &pos); | ||
285 | curl_easy_setopt (c, CURLOPT_UPLOAD, 1L); | ||
286 | curl_easy_setopt (c, CURLOPT_INFILESIZE, (long) PUT_SIZE); | ||
287 | curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); | ||
288 | curl_easy_setopt (c, CURLOPT_TIMEOUT_MS, CURL_TIMEOUT); | ||
289 | if (oneone) | ||
290 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); | ||
291 | else | ||
292 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); | ||
293 | curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT_MS, CURL_TIMEOUT); | ||
294 | /* NOTE: use of CONNECTTIMEOUT without also | ||
295 | * setting NOSIGNAL results in really weird | ||
296 | * crashes on my system! */ | ||
297 | curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); | ||
298 | |||
299 | |||
300 | |||
301 | mret = curl_multi_add_handle (multi, c); | ||
302 | if (mret != CURLM_OK) | 321 | if (mret != CURLM_OK) |
303 | { | 322 | { |
304 | curl_multi_cleanup (multi); | 323 | curl_multi_remove_handle (multi, c); |
305 | curl_easy_cleanup (c); | 324 | curl_multi_cleanup (multi); |
306 | zzuf_socat_stop (); | 325 | curl_easy_cleanup (c); |
307 | MHD_stop_daemon (d); | 326 | zzuf_socat_stop (); |
308 | return 1024; | 327 | MHD_stop_daemon (d); |
309 | } | 328 | return 2048; |
310 | start = time (NULL); | 329 | } |
311 | while ((time (NULL) - start < 5) && (c != NULL)) | 330 | if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &max)) |
312 | { | 331 | { |
313 | max = 0; | 332 | curl_multi_remove_handle (multi, c); |
314 | FD_ZERO (&rs); | 333 | curl_multi_cleanup (multi); |
315 | FD_ZERO (&ws); | 334 | curl_easy_cleanup (c); |
316 | FD_ZERO (&es); | 335 | zzuf_socat_stop (); |
317 | curl_multi_perform (multi, &running); | 336 | MHD_stop_daemon (d); |
318 | mret = curl_multi_fdset (multi, &rs, &ws, &es, &max); | 337 | return 4096; |
319 | if (mret != CURLM_OK) | 338 | } |
320 | { | 339 | tv.tv_sec = 0; |
321 | curl_multi_remove_handle (multi, c); | 340 | tv.tv_usec = 1000; |
322 | curl_multi_cleanup (multi); | 341 | select (max + 1, &rs, &ws, &es, &tv); |
323 | curl_easy_cleanup (c); | 342 | curl_multi_perform (multi, &running); |
324 | zzuf_socat_stop (); | 343 | if (running == 0) |
325 | MHD_stop_daemon (d); | 344 | { |
326 | return 2048; | 345 | curl_multi_info_read (multi, &running); |
327 | } | 346 | curl_multi_remove_handle (multi, c); |
328 | if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &max)) | 347 | curl_easy_cleanup (c); |
329 | { | 348 | c = NULL; |
330 | curl_multi_remove_handle (multi, c); | 349 | } |
331 | curl_multi_cleanup (multi); | 350 | MHD_run (d); |
332 | curl_easy_cleanup (c); | ||
333 | zzuf_socat_stop (); | ||
334 | MHD_stop_daemon (d); | ||
335 | return 4096; | ||
336 | } | ||
337 | tv.tv_sec = 0; | ||
338 | tv.tv_usec = 1000; | ||
339 | select (max + 1, &rs, &ws, &es, &tv); | ||
340 | curl_multi_perform (multi, &running); | ||
341 | if (running == 0) | ||
342 | { | ||
343 | curl_multi_info_read (multi, &running); | ||
344 | curl_multi_remove_handle (multi, c); | ||
345 | curl_easy_cleanup (c); | ||
346 | c = NULL; | ||
347 | } | ||
348 | MHD_run (d); | ||
349 | } | ||
350 | if (c != NULL) | ||
351 | { | ||
352 | curl_multi_remove_handle (multi, c); | ||
353 | curl_easy_cleanup (c); | ||
354 | } | ||
355 | } | 351 | } |
352 | if (c != NULL) | ||
353 | { | ||
354 | curl_multi_remove_handle (multi, c); | ||
355 | curl_easy_cleanup (c); | ||
356 | } | ||
357 | } | ||
356 | fprintf (stderr, "\n"); | 358 | fprintf (stderr, "\n"); |
357 | zzuf_socat_stop (); | 359 | zzuf_socat_stop (); |
358 | curl_multi_cleanup (multi); | 360 | curl_multi_cleanup (multi); |
@@ -365,19 +367,19 @@ int | |||
365 | main (int argc, char *const *argv) | 367 | main (int argc, char *const *argv) |
366 | { | 368 | { |
367 | unsigned int errorCount = 0; | 369 | unsigned int errorCount = 0; |
368 | (void)argc; /* Unused. Silent compiler warning. */ | 370 | (void) argc; /* Unused. Silent compiler warning. */ |
369 | 371 | ||
370 | oneone = (NULL != strrchr (argv[0], (int) '/')) ? | 372 | oneone = (NULL != strrchr (argv[0], (int) '/')) ? |
371 | (NULL != strstr (strrchr (argv[0], (int) '/'), "11")) : 0; | 373 | (NULL != strstr (strrchr (argv[0], (int) '/'), "11")) : 0; |
372 | if (0 != curl_global_init (CURL_GLOBAL_WIN32)) | 374 | if (0 != curl_global_init (CURL_GLOBAL_WIN32)) |
373 | return 2; | 375 | return 2; |
374 | put_buffer = malloc (PUT_SIZE); | 376 | put_buffer = malloc (PUT_SIZE); |
375 | memset (put_buffer, 1, PUT_SIZE); | 377 | memset (put_buffer, 1, PUT_SIZE); |
376 | if (MHD_YES == MHD_is_feature_supported(MHD_FEATURE_THREADS)) | 378 | if (MHD_YES == MHD_is_feature_supported (MHD_FEATURE_THREADS)) |
377 | { | 379 | { |
378 | errorCount += testInternalPut (); | 380 | errorCount += testInternalPut (); |
379 | errorCount += testMultithreadedPut (); | 381 | errorCount += testMultithreadedPut (); |
380 | } | 382 | } |
381 | errorCount += testExternalPut (); | 383 | errorCount += testExternalPut (); |
382 | free (put_buffer); | 384 | free (put_buffer); |
383 | if (errorCount != 0) | 385 | if (errorCount != 0) |