diff options
Diffstat (limited to 'src/testcurl/test_put.c')
-rw-r--r-- | src/testcurl/test_put.c | 335 |
1 files changed, 173 insertions, 162 deletions
diff --git a/src/testcurl/test_put.c b/src/testcurl/test_put.c index fd56e2b2..df399268 100644 --- a/src/testcurl/test_put.c +++ b/src/testcurl/test_put.c | |||
@@ -37,10 +37,10 @@ | |||
37 | #include <unistd.h> | 37 | #include <unistd.h> |
38 | #endif | 38 | #endif |
39 | 39 | ||
40 | #if defined(CPU_COUNT) && (CPU_COUNT+0) < 2 | 40 | #if defined(CPU_COUNT) && (CPU_COUNT + 0) < 2 |
41 | #undef CPU_COUNT | 41 | #undef CPU_COUNT |
42 | #endif | 42 | #endif |
43 | #if !defined(CPU_COUNT) | 43 | #if ! defined(CPU_COUNT) |
44 | #define CPU_COUNT 2 | 44 | #define CPU_COUNT 2 |
45 | #endif | 45 | #endif |
46 | 46 | ||
@@ -91,28 +91,28 @@ ahc_echo (void *cls, | |||
91 | int *done = cls; | 91 | int *done = cls; |
92 | struct MHD_Response *response; | 92 | struct MHD_Response *response; |
93 | int ret; | 93 | int ret; |
94 | (void)version;(void)unused; /* Unused. Silent compiler warning. */ | 94 | (void) version; (void) unused; /* Unused. Silent compiler warning. */ |
95 | 95 | ||
96 | if (0 != strcasecmp ("PUT", method)) | 96 | if (0 != strcasecmp ("PUT", method)) |
97 | return MHD_NO; /* unexpected method */ | 97 | return MHD_NO; /* unexpected method */ |
98 | if ((*done) == 0) | 98 | if ((*done) == 0) |
99 | { | ||
100 | if (*upload_data_size != 8) | ||
101 | return MHD_YES; /* not yet ready */ | ||
102 | if (0 == memcmp (upload_data, "Hello123", 8)) | ||
99 | { | 103 | { |
100 | if (*upload_data_size != 8) | 104 | *upload_data_size = 0; |
101 | return MHD_YES; /* not yet ready */ | ||
102 | if (0 == memcmp (upload_data, "Hello123", 8)) | ||
103 | { | ||
104 | *upload_data_size = 0; | ||
105 | } | ||
106 | else | ||
107 | { | ||
108 | printf ("Invalid upload data `%8s'!\n", upload_data); | ||
109 | return MHD_NO; | ||
110 | } | ||
111 | *done = 1; | ||
112 | return MHD_YES; | ||
113 | } | 105 | } |
106 | else | ||
107 | { | ||
108 | printf ("Invalid upload data `%8s'!\n", upload_data); | ||
109 | return MHD_NO; | ||
110 | } | ||
111 | *done = 1; | ||
112 | return MHD_YES; | ||
113 | } | ||
114 | response = MHD_create_response_from_buffer (strlen (url), (void*) url, | 114 | response = MHD_create_response_from_buffer (strlen (url), (void*) url, |
115 | MHD_RESPMEM_MUST_COPY); | 115 | MHD_RESPMEM_MUST_COPY); |
116 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); | 116 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); |
117 | MHD_destroy_response (response); | 117 | MHD_destroy_response (response); |
118 | return ret; | 118 | return ret; |
@@ -134,11 +134,11 @@ testInternalPut () | |||
134 | if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) | 134 | if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) |
135 | port = 0; | 135 | port = 0; |
136 | else | 136 | else |
137 | { | 137 | { |
138 | port = 1450; | 138 | port = 1450; |
139 | if (oneone) | 139 | if (oneone) |
140 | port += 10; | 140 | port += 10; |
141 | } | 141 | } |
142 | 142 | ||
143 | cbc.buf = buf; | 143 | cbc.buf = buf; |
144 | cbc.size = 2048; | 144 | cbc.size = 2048; |
@@ -149,16 +149,18 @@ testInternalPut () | |||
149 | if (d == NULL) | 149 | if (d == NULL) |
150 | return 1; | 150 | return 1; |
151 | if (0 == port) | 151 | if (0 == port) |
152 | { | ||
153 | const union MHD_DaemonInfo *dinfo; | ||
154 | dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); | ||
155 | if ((NULL == dinfo) ||(0 == dinfo->port) ) | ||
152 | { | 156 | { |
153 | const union MHD_DaemonInfo *dinfo; | 157 | MHD_stop_daemon (d); return 32; |
154 | dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); | ||
155 | if (NULL == dinfo || 0 == dinfo->port) | ||
156 | { MHD_stop_daemon (d); return 32; } | ||
157 | port = (int)dinfo->port; | ||
158 | } | 158 | } |
159 | port = (int) dinfo->port; | ||
160 | } | ||
159 | c = curl_easy_init (); | 161 | c = curl_easy_init (); |
160 | curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world"); | 162 | curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world"); |
161 | curl_easy_setopt (c, CURLOPT_PORT, (long)port); | 163 | curl_easy_setopt (c, CURLOPT_PORT, (long) port); |
162 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); | 164 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); |
163 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); | 165 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); |
164 | curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer); | 166 | curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer); |
@@ -177,14 +179,14 @@ testInternalPut () | |||
177 | * crashes on my system! */ | 179 | * crashes on my system! */ |
178 | curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); | 180 | curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); |
179 | if (CURLE_OK != (errornum = curl_easy_perform (c))) | 181 | if (CURLE_OK != (errornum = curl_easy_perform (c))) |
180 | { | 182 | { |
181 | fprintf (stderr, | 183 | fprintf (stderr, |
182 | "curl_easy_perform failed: `%s'\n", | 184 | "curl_easy_perform failed: `%s'\n", |
183 | curl_easy_strerror (errornum)); | 185 | curl_easy_strerror (errornum)); |
184 | curl_easy_cleanup (c); | 186 | curl_easy_cleanup (c); |
185 | MHD_stop_daemon (d); | 187 | MHD_stop_daemon (d); |
186 | return 2; | 188 | return 2; |
187 | } | 189 | } |
188 | curl_easy_cleanup (c); | 190 | curl_easy_cleanup (c); |
189 | MHD_stop_daemon (d); | 191 | MHD_stop_daemon (d); |
190 | if (cbc.pos != strlen ("/hello_world")) | 192 | if (cbc.pos != strlen ("/hello_world")) |
@@ -209,31 +211,34 @@ testMultithreadedPut () | |||
209 | if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) | 211 | if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) |
210 | port = 0; | 212 | port = 0; |
211 | else | 213 | else |
212 | { | 214 | { |
213 | port = 1451; | 215 | port = 1451; |
214 | if (oneone) | 216 | if (oneone) |
215 | port += 10; | 217 | port += 10; |
216 | } | 218 | } |
217 | 219 | ||
218 | cbc.buf = buf; | 220 | cbc.buf = buf; |
219 | cbc.size = 2048; | 221 | cbc.size = 2048; |
220 | cbc.pos = 0; | 222 | cbc.pos = 0; |
221 | d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, | 223 | d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION |
224 | | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, | ||
222 | port, | 225 | port, |
223 | NULL, NULL, &ahc_echo, &done_flag, MHD_OPTION_END); | 226 | NULL, NULL, &ahc_echo, &done_flag, MHD_OPTION_END); |
224 | if (d == NULL) | 227 | if (d == NULL) |
225 | return 16; | 228 | return 16; |
226 | if (0 == port) | 229 | if (0 == port) |
230 | { | ||
231 | const union MHD_DaemonInfo *dinfo; | ||
232 | dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); | ||
233 | if ((NULL == dinfo) ||(0 == dinfo->port) ) | ||
227 | { | 234 | { |
228 | const union MHD_DaemonInfo *dinfo; | 235 | MHD_stop_daemon (d); return 32; |
229 | dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); | ||
230 | if (NULL == dinfo || 0 == dinfo->port) | ||
231 | { MHD_stop_daemon (d); return 32; } | ||
232 | port = (int)dinfo->port; | ||
233 | } | 236 | } |
237 | port = (int) dinfo->port; | ||
238 | } | ||
234 | c = curl_easy_init (); | 239 | c = curl_easy_init (); |
235 | curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world"); | 240 | curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world"); |
236 | curl_easy_setopt (c, CURLOPT_PORT, (long)port); | 241 | curl_easy_setopt (c, CURLOPT_PORT, (long) port); |
237 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); | 242 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); |
238 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); | 243 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); |
239 | curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer); | 244 | curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer); |
@@ -252,14 +257,14 @@ testMultithreadedPut () | |||
252 | * crashes on my system! */ | 257 | * crashes on my system! */ |
253 | curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); | 258 | curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); |
254 | if (CURLE_OK != (errornum = curl_easy_perform (c))) | 259 | if (CURLE_OK != (errornum = curl_easy_perform (c))) |
255 | { | 260 | { |
256 | fprintf (stderr, | 261 | fprintf (stderr, |
257 | "curl_easy_perform failed: `%s'\n", | 262 | "curl_easy_perform failed: `%s'\n", |
258 | curl_easy_strerror (errornum)); | 263 | curl_easy_strerror (errornum)); |
259 | curl_easy_cleanup (c); | 264 | curl_easy_cleanup (c); |
260 | MHD_stop_daemon (d); | 265 | MHD_stop_daemon (d); |
261 | return 32; | 266 | return 32; |
262 | } | 267 | } |
263 | curl_easy_cleanup (c); | 268 | curl_easy_cleanup (c); |
264 | MHD_stop_daemon (d); | 269 | MHD_stop_daemon (d); |
265 | if (cbc.pos != strlen ("/hello_world")) | 270 | if (cbc.pos != strlen ("/hello_world")) |
@@ -285,11 +290,11 @@ testMultithreadedPoolPut () | |||
285 | if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) | 290 | if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) |
286 | port = 0; | 291 | port = 0; |
287 | else | 292 | else |
288 | { | 293 | { |
289 | port = 1452; | 294 | port = 1452; |
290 | if (oneone) | 295 | if (oneone) |
291 | port += 10; | 296 | port += 10; |
292 | } | 297 | } |
293 | 298 | ||
294 | cbc.buf = buf; | 299 | cbc.buf = buf; |
295 | cbc.size = 2048; | 300 | cbc.size = 2048; |
@@ -301,16 +306,18 @@ testMultithreadedPoolPut () | |||
301 | if (d == NULL) | 306 | if (d == NULL) |
302 | return 16; | 307 | return 16; |
303 | if (0 == port) | 308 | if (0 == port) |
309 | { | ||
310 | const union MHD_DaemonInfo *dinfo; | ||
311 | dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); | ||
312 | if ((NULL == dinfo) ||(0 == dinfo->port) ) | ||
304 | { | 313 | { |
305 | const union MHD_DaemonInfo *dinfo; | 314 | MHD_stop_daemon (d); return 32; |
306 | dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); | ||
307 | if (NULL == dinfo || 0 == dinfo->port) | ||
308 | { MHD_stop_daemon (d); return 32; } | ||
309 | port = (int)dinfo->port; | ||
310 | } | 315 | } |
316 | port = (int) dinfo->port; | ||
317 | } | ||
311 | c = curl_easy_init (); | 318 | c = curl_easy_init (); |
312 | curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world"); | 319 | curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world"); |
313 | curl_easy_setopt (c, CURLOPT_PORT, (long)port); | 320 | curl_easy_setopt (c, CURLOPT_PORT, (long) port); |
314 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); | 321 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); |
315 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); | 322 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); |
316 | curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer); | 323 | curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer); |
@@ -329,14 +336,14 @@ testMultithreadedPoolPut () | |||
329 | * crashes on my system! */ | 336 | * crashes on my system! */ |
330 | curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); | 337 | curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); |
331 | if (CURLE_OK != (errornum = curl_easy_perform (c))) | 338 | if (CURLE_OK != (errornum = curl_easy_perform (c))) |
332 | { | 339 | { |
333 | fprintf (stderr, | 340 | fprintf (stderr, |
334 | "curl_easy_perform failed: `%s'\n", | 341 | "curl_easy_perform failed: `%s'\n", |
335 | curl_easy_strerror (errornum)); | 342 | curl_easy_strerror (errornum)); |
336 | curl_easy_cleanup (c); | 343 | curl_easy_cleanup (c); |
337 | MHD_stop_daemon (d); | 344 | MHD_stop_daemon (d); |
338 | return 32; | 345 | return 32; |
339 | } | 346 | } |
340 | curl_easy_cleanup (c); | 347 | curl_easy_cleanup (c); |
341 | MHD_stop_daemon (d); | 348 | MHD_stop_daemon (d); |
342 | if (cbc.pos != strlen ("/hello_world")) | 349 | if (cbc.pos != strlen ("/hello_world")) |
@@ -373,11 +380,11 @@ testExternalPut () | |||
373 | if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) | 380 | if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) |
374 | port = 0; | 381 | port = 0; |
375 | else | 382 | else |
376 | { | 383 | { |
377 | port = 1453; | 384 | port = 1453; |
378 | if (oneone) | 385 | if (oneone) |
379 | port += 10; | 386 | port += 10; |
380 | } | 387 | } |
381 | 388 | ||
382 | multi = NULL; | 389 | multi = NULL; |
383 | cbc.buf = buf; | 390 | cbc.buf = buf; |
@@ -389,17 +396,19 @@ testExternalPut () | |||
389 | if (d == NULL) | 396 | if (d == NULL) |
390 | return 256; | 397 | return 256; |
391 | if (0 == port) | 398 | if (0 == port) |
399 | { | ||
400 | const union MHD_DaemonInfo *dinfo; | ||
401 | dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); | ||
402 | if ((NULL == dinfo) ||(0 == dinfo->port) ) | ||
392 | { | 403 | { |
393 | const union MHD_DaemonInfo *dinfo; | 404 | MHD_stop_daemon (d); return 32; |
394 | dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); | ||
395 | if (NULL == dinfo || 0 == dinfo->port) | ||
396 | { MHD_stop_daemon (d); return 32; } | ||
397 | port = (int)dinfo->port; | ||
398 | } | 405 | } |
406 | port = (int) dinfo->port; | ||
407 | } | ||
399 | c = curl_easy_init (); | 408 | c = curl_easy_init (); |
400 | curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world"); | 409 | curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world"); |
401 | curl_easy_setopt (c, CURLOPT_PORT, (long)port); | 410 | curl_easy_setopt (c, CURLOPT_PORT, (long) port); |
402 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); | 411 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); |
403 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); | 412 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); |
404 | curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer); | 413 | curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer); |
405 | curl_easy_setopt (c, CURLOPT_READDATA, &pos); | 414 | curl_easy_setopt (c, CURLOPT_READDATA, &pos); |
@@ -420,90 +429,92 @@ curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); | |||
420 | 429 | ||
421 | multi = curl_multi_init (); | 430 | multi = curl_multi_init (); |
422 | if (multi == NULL) | 431 | if (multi == NULL) |
432 | { | ||
433 | curl_easy_cleanup (c); | ||
434 | MHD_stop_daemon (d); | ||
435 | return 512; | ||
436 | } | ||
437 | mret = curl_multi_add_handle (multi, c); | ||
438 | if (mret != CURLM_OK) | ||
439 | { | ||
440 | curl_multi_cleanup (multi); | ||
441 | curl_easy_cleanup (c); | ||
442 | MHD_stop_daemon (d); | ||
443 | return 1024; | ||
444 | } | ||
445 | start = time (NULL); | ||
446 | while ((time (NULL) - start < 5) && (multi != NULL)) | ||
447 | { | ||
448 | maxsock = MHD_INVALID_SOCKET; | ||
449 | maxposixs = -1; | ||
450 | FD_ZERO (&rs); | ||
451 | FD_ZERO (&ws); | ||
452 | FD_ZERO (&es); | ||
453 | curl_multi_perform (multi, &running); | ||
454 | mret = curl_multi_fdset (multi, &rs, &ws, &es, &maxposixs); | ||
455 | if (mret != CURLM_OK) | ||
423 | { | 456 | { |
457 | curl_multi_remove_handle (multi, c); | ||
458 | curl_multi_cleanup (multi); | ||
424 | curl_easy_cleanup (c); | 459 | curl_easy_cleanup (c); |
425 | MHD_stop_daemon (d); | 460 | MHD_stop_daemon (d); |
426 | return 512; | 461 | return 2048; |
427 | } | 462 | } |
428 | mret = curl_multi_add_handle (multi, c); | 463 | if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &maxsock)) |
429 | if (mret != CURLM_OK) | ||
430 | { | 464 | { |
465 | curl_multi_remove_handle (multi, c); | ||
431 | curl_multi_cleanup (multi); | 466 | curl_multi_cleanup (multi); |
432 | curl_easy_cleanup (c); | 467 | curl_easy_cleanup (c); |
433 | MHD_stop_daemon (d); | 468 | MHD_stop_daemon (d); |
434 | return 1024; | 469 | return 4096; |
435 | } | 470 | } |
436 | start = time (NULL); | ||
437 | while ((time (NULL) - start < 5) && (multi != NULL)) | ||
438 | { | ||
439 | maxsock = MHD_INVALID_SOCKET; | ||
440 | maxposixs = -1; | ||
441 | FD_ZERO (&rs); | ||
442 | FD_ZERO (&ws); | ||
443 | FD_ZERO (&es); | ||
444 | curl_multi_perform (multi, &running); | ||
445 | mret = curl_multi_fdset (multi, &rs, &ws, &es, &maxposixs); | ||
446 | if (mret != CURLM_OK) | ||
447 | { | ||
448 | curl_multi_remove_handle (multi, c); | ||
449 | curl_multi_cleanup (multi); | ||
450 | curl_easy_cleanup (c); | ||
451 | MHD_stop_daemon (d); | ||
452 | return 2048; | ||
453 | } | ||
454 | if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &maxsock)) | ||
455 | { | ||
456 | curl_multi_remove_handle (multi, c); | ||
457 | curl_multi_cleanup (multi); | ||
458 | curl_easy_cleanup (c); | ||
459 | MHD_stop_daemon (d); | ||
460 | return 4096; | ||
461 | } | ||
462 | #ifdef MHD_POSIX_SOCKETS | 471 | #ifdef MHD_POSIX_SOCKETS |
463 | if (maxsock > maxposixs) | 472 | if (maxsock > maxposixs) |
464 | maxposixs = maxsock; | 473 | maxposixs = maxsock; |
465 | #endif /* MHD_POSIX_SOCKETS */ | 474 | #endif /* MHD_POSIX_SOCKETS */ |
466 | tv.tv_sec = 0; | 475 | tv.tv_sec = 0; |
467 | tv.tv_usec = 1000; | 476 | tv.tv_usec = 1000; |
468 | if (-1 == select (maxposixs + 1, &rs, &ws, &es, &tv)) | 477 | if (-1 == select (maxposixs + 1, &rs, &ws, &es, &tv)) |
469 | { | 478 | { |
470 | #ifdef MHD_POSIX_SOCKETS | 479 | #ifdef MHD_POSIX_SOCKETS |
471 | if (EINTR != errno) | 480 | if (EINTR != errno) |
472 | abort (); | 481 | abort (); |
473 | #else | 482 | #else |
474 | if (WSAEINVAL != WSAGetLastError() || 0 != rs.fd_count || 0 != ws.fd_count || 0 != es.fd_count) | 483 | if ((WSAEINVAL != WSAGetLastError ()) ||(0 != rs.fd_count) ||(0 != |
475 | _exit (99); | 484 | ws.fd_count) |
476 | Sleep (1000); | 485 | ||(0 != es.fd_count) ) |
486 | _exit (99); | ||
487 | Sleep (1000); | ||
477 | #endif | 488 | #endif |
478 | } | ||
479 | curl_multi_perform (multi, &running); | ||
480 | if (running == 0) | ||
481 | { | ||
482 | msg = curl_multi_info_read (multi, &running); | ||
483 | if (msg == NULL) | ||
484 | break; | ||
485 | if (msg->msg == CURLMSG_DONE) | ||
486 | { | ||
487 | if (msg->data.result != CURLE_OK) | ||
488 | printf ("%s failed at %s:%d: `%s'\n", | ||
489 | "curl_multi_perform", | ||
490 | __FILE__, | ||
491 | __LINE__, curl_easy_strerror (msg->data.result)); | ||
492 | curl_multi_remove_handle (multi, c); | ||
493 | curl_multi_cleanup (multi); | ||
494 | curl_easy_cleanup (c); | ||
495 | c = NULL; | ||
496 | multi = NULL; | ||
497 | } | ||
498 | } | ||
499 | MHD_run (d); | ||
500 | } | 489 | } |
501 | if (multi != NULL) | 490 | curl_multi_perform (multi, &running); |
491 | if (running == 0) | ||
502 | { | 492 | { |
503 | curl_multi_remove_handle (multi, c); | 493 | msg = curl_multi_info_read (multi, &running); |
504 | curl_easy_cleanup (c); | 494 | if (msg == NULL) |
505 | curl_multi_cleanup (multi); | 495 | break; |
496 | if (msg->msg == CURLMSG_DONE) | ||
497 | { | ||
498 | if (msg->data.result != CURLE_OK) | ||
499 | printf ("%s failed at %s:%d: `%s'\n", | ||
500 | "curl_multi_perform", | ||
501 | __FILE__, | ||
502 | __LINE__, curl_easy_strerror (msg->data.result)); | ||
503 | curl_multi_remove_handle (multi, c); | ||
504 | curl_multi_cleanup (multi); | ||
505 | curl_easy_cleanup (c); | ||
506 | c = NULL; | ||
507 | multi = NULL; | ||
508 | } | ||
506 | } | 509 | } |
510 | MHD_run (d); | ||
511 | } | ||
512 | if (multi != NULL) | ||
513 | { | ||
514 | curl_multi_remove_handle (multi, c); | ||
515 | curl_easy_cleanup (c); | ||
516 | curl_multi_cleanup (multi); | ||
517 | } | ||
507 | MHD_stop_daemon (d); | 518 | MHD_stop_daemon (d); |
508 | if (cbc.pos != strlen ("/hello_world")) | 519 | if (cbc.pos != strlen ("/hello_world")) |
509 | return 8192; | 520 | return 8192; |
@@ -518,19 +529,19 @@ int | |||
518 | main (int argc, char *const *argv) | 529 | main (int argc, char *const *argv) |
519 | { | 530 | { |
520 | unsigned int errorCount = 0; | 531 | unsigned int errorCount = 0; |
521 | (void)argc; /* Unused. Silent compiler warning. */ | 532 | (void) argc; /* Unused. Silent compiler warning. */ |
522 | 533 | ||
523 | if (NULL == argv || 0 == argv[0]) | 534 | if ((NULL == argv)||(0 == argv[0])) |
524 | return 99; | 535 | return 99; |
525 | oneone = has_in_name (argv[0], "11"); | 536 | oneone = has_in_name (argv[0], "11"); |
526 | if (0 != curl_global_init (CURL_GLOBAL_WIN32)) | 537 | if (0 != curl_global_init (CURL_GLOBAL_WIN32)) |
527 | return 2; | 538 | return 2; |
528 | if (MHD_YES == MHD_is_feature_supported(MHD_FEATURE_THREADS)) | 539 | if (MHD_YES == MHD_is_feature_supported (MHD_FEATURE_THREADS)) |
529 | { | 540 | { |
530 | errorCount += testInternalPut (); | 541 | errorCount += testInternalPut (); |
531 | errorCount += testMultithreadedPut (); | 542 | errorCount += testMultithreadedPut (); |
532 | errorCount += testMultithreadedPoolPut (); | 543 | errorCount += testMultithreadedPoolPut (); |
533 | } | 544 | } |
534 | errorCount += testExternalPut (); | 545 | errorCount += testExternalPut (); |
535 | if (errorCount != 0) | 546 | if (errorCount != 0) |
536 | fprintf (stderr, "Error (code: %u)\n", errorCount); | 547 | fprintf (stderr, "Error (code: %u)\n", errorCount); |