aboutsummaryrefslogtreecommitdiff
path: root/src/testcurl/test_postform.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testcurl/test_postform.c')
-rw-r--r--src/testcurl/test_postform.c385
1 files changed, 198 insertions, 187 deletions
diff --git a/src/testcurl/test_postform.c b/src/testcurl/test_postform.c
index 723bde0f..c4fbd5d5 100644
--- a/src/testcurl/test_postform.c
+++ b/src/testcurl/test_postform.c
@@ -43,10 +43,10 @@
43 43
44#include "mhd_has_in_name.h" 44#include "mhd_has_in_name.h"
45 45
46#if defined(CPU_COUNT) && (CPU_COUNT+0) < 2 46#if defined(CPU_COUNT) && (CPU_COUNT + 0) < 2
47#undef CPU_COUNT 47#undef CPU_COUNT
48#endif 48#endif
49#if !defined(CPU_COUNT) 49#if ! defined(CPU_COUNT)
50#define CPU_COUNT 2 50#define CPU_COUNT 2
51#endif 51#endif
52 52
@@ -62,12 +62,12 @@ struct CBC
62 62
63static void 63static void
64completed_cb (void *cls, 64completed_cb (void *cls,
65 struct MHD_Connection *connection, 65 struct MHD_Connection *connection,
66 void **con_cls, 66 void **con_cls,
67 enum MHD_RequestTerminationCode toe) 67 enum MHD_RequestTerminationCode toe)
68{ 68{
69 struct MHD_PostProcessor *pp = *con_cls; 69 struct MHD_PostProcessor *pp = *con_cls;
70 (void)cls;(void)connection;(void)toe; /* Unused. Silent compiler warning. */ 70 (void) cls; (void) connection; (void) toe; /* Unused. Silent compiler warning. */
71 71
72 if (NULL != pp) 72 if (NULL != pp)
73 MHD_destroy_post_processor (pp); 73 MHD_destroy_post_processor (pp);
@@ -103,8 +103,8 @@ post_iterator (void *cls,
103 const char *value, uint64_t off, size_t size) 103 const char *value, uint64_t off, size_t size)
104{ 104{
105 int *eok = cls; 105 int *eok = cls;
106 (void)kind;(void)filename;(void)content_type; /* Unused. Silent compiler warning. */ 106 (void) kind; (void) filename; (void) content_type; /* Unused. Silent compiler warning. */
107 (void)transfer_encoding;(void)off; /* Unused. Silent compiler warning. */ 107 (void) transfer_encoding; (void) off; /* Unused. Silent compiler warning. */
108 108
109#if 0 109#if 0
110 fprintf (stderr, "PI sees %s-%.*s\n", key, size, value); 110 fprintf (stderr, "PI sees %s-%.*s\n", key, size, value);
@@ -132,34 +132,34 @@ ahc_echo (void *cls,
132 struct MHD_Response *response; 132 struct MHD_Response *response;
133 struct MHD_PostProcessor *pp; 133 struct MHD_PostProcessor *pp;
134 int ret; 134 int ret;
135 (void)cls;(void)version; /* Unused. Silent compiler warning. */ 135 (void) cls; (void) version; /* Unused. Silent compiler warning. */
136 136
137 if (0 != strcmp ("POST", method)) 137 if (0 != strcmp ("POST", method))
138 { 138 {
139 printf ("METHOD: %s\n", method); 139 printf ("METHOD: %s\n", method);
140 return MHD_NO; /* unexpected method */ 140 return MHD_NO; /* unexpected method */
141 } 141 }
142 pp = *unused; 142 pp = *unused;
143 if (pp == NULL) 143 if (pp == NULL)
144 { 144 {
145 eok = 0; 145 eok = 0;
146 pp = MHD_create_post_processor (connection, 1024, &post_iterator, &eok); 146 pp = MHD_create_post_processor (connection, 1024, &post_iterator, &eok);
147 if (pp == NULL) 147 if (pp == NULL)
148 abort (); 148 abort ();
149 *unused = pp; 149 *unused = pp;
150 } 150 }
151 MHD_post_process (pp, upload_data, *upload_data_size); 151 MHD_post_process (pp, upload_data, *upload_data_size);
152 if ((eok == 3) && (0 == *upload_data_size)) 152 if ((eok == 3) && (0 == *upload_data_size))
153 { 153 {
154 response = MHD_create_response_from_buffer (strlen (url), 154 response = MHD_create_response_from_buffer (strlen (url),
155 (void *) url, 155 (void *) url,
156 MHD_RESPMEM_MUST_COPY); 156 MHD_RESPMEM_MUST_COPY);
157 ret = MHD_queue_response (connection, MHD_HTTP_OK, response); 157 ret = MHD_queue_response (connection, MHD_HTTP_OK, response);
158 MHD_destroy_response (response); 158 MHD_destroy_response (response);
159 MHD_destroy_post_processor (pp); 159 MHD_destroy_post_processor (pp);
160 *unused = NULL; 160 *unused = NULL;
161 return ret; 161 return ret;
162 } 162 }
163 *upload_data_size = 0; 163 *upload_data_size = 0;
164 return MHD_YES; 164 return MHD_YES;
165} 165}
@@ -192,32 +192,34 @@ testInternalPost ()
192 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) 192 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
193 port = 0; 193 port = 0;
194 else 194 else
195 { 195 {
196 port = 1390; 196 port = 1390;
197 if (oneone) 197 if (oneone)
198 port += 10; 198 port += 10;
199 } 199 }
200 200
201 cbc.buf = buf; 201 cbc.buf = buf;
202 cbc.size = 2048; 202 cbc.size = 2048;
203 cbc.pos = 0; 203 cbc.pos = 0;
204 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, 204 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG,
205 port, NULL, NULL, &ahc_echo, NULL, 205 port, NULL, NULL, &ahc_echo, NULL,
206 MHD_OPTION_NOTIFY_COMPLETED, &completed_cb, NULL, 206 MHD_OPTION_NOTIFY_COMPLETED, &completed_cb, NULL,
207 MHD_OPTION_END); 207 MHD_OPTION_END);
208 if (d == NULL) 208 if (d == NULL)
209 return 1; 209 return 1;
210 if (0 == port) 210 if (0 == port)
211 {
212 const union MHD_DaemonInfo *dinfo;
213 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
214 if ((NULL == dinfo) ||(0 == dinfo->port) )
211 { 215 {
212 const union MHD_DaemonInfo *dinfo; 216 MHD_stop_daemon (d); return 32;
213 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
214 if (NULL == dinfo || 0 == dinfo->port)
215 { MHD_stop_daemon (d); return 32; }
216 port = (int)dinfo->port;
217 } 217 }
218 port = (int) dinfo->port;
219 }
218 c = curl_easy_init (); 220 c = curl_easy_init ();
219 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world"); 221 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world");
220 curl_easy_setopt (c, CURLOPT_PORT, (long)port); 222 curl_easy_setopt (c, CURLOPT_PORT, (long) port);
221 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 223 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
222 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 224 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
223 pd = make_form (); 225 pd = make_form ();
@@ -234,15 +236,15 @@ testInternalPost ()
234 * crashes on my system! */ 236 * crashes on my system! */
235 curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); 237 curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L);
236 if (CURLE_OK != (errornum = curl_easy_perform (c))) 238 if (CURLE_OK != (errornum = curl_easy_perform (c)))
237 { 239 {
238 fprintf (stderr, 240 fprintf (stderr,
239 "curl_easy_perform failed: `%s'\n", 241 "curl_easy_perform failed: `%s'\n",
240 curl_easy_strerror (errornum)); 242 curl_easy_strerror (errornum));
241 curl_easy_cleanup (c); 243 curl_easy_cleanup (c);
242 curl_formfree (pd); 244 curl_formfree (pd);
243 MHD_stop_daemon (d); 245 MHD_stop_daemon (d);
244 return 2; 246 return 2;
245 } 247 }
246 curl_easy_cleanup (c); 248 curl_easy_cleanup (c);
247 curl_formfree (pd); 249 curl_formfree (pd);
248 MHD_stop_daemon (d); 250 MHD_stop_daemon (d);
@@ -267,32 +269,35 @@ testMultithreadedPost ()
267 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) 269 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
268 port = 0; 270 port = 0;
269 else 271 else
270 { 272 {
271 port = 1390; 273 port = 1390;
272 if (oneone) 274 if (oneone)
273 port += 10; 275 port += 10;
274 } 276 }
275 277
276 cbc.buf = buf; 278 cbc.buf = buf;
277 cbc.size = 2048; 279 cbc.size = 2048;
278 cbc.pos = 0; 280 cbc.pos = 0;
279 d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, 281 d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION
282 | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG,
280 port, NULL, NULL, &ahc_echo, NULL, 283 port, NULL, NULL, &ahc_echo, NULL,
281 MHD_OPTION_NOTIFY_COMPLETED, &completed_cb, NULL, 284 MHD_OPTION_NOTIFY_COMPLETED, &completed_cb, NULL,
282 MHD_OPTION_END); 285 MHD_OPTION_END);
283 if (d == NULL) 286 if (d == NULL)
284 return 16; 287 return 16;
285 if (0 == port) 288 if (0 == port)
289 {
290 const union MHD_DaemonInfo *dinfo;
291 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
292 if ((NULL == dinfo) ||(0 == dinfo->port) )
286 { 293 {
287 const union MHD_DaemonInfo *dinfo; 294 MHD_stop_daemon (d); return 32;
288 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
289 if (NULL == dinfo || 0 == dinfo->port)
290 { MHD_stop_daemon (d); return 32; }
291 port = (int)dinfo->port;
292 } 295 }
296 port = (int) dinfo->port;
297 }
293 c = curl_easy_init (); 298 c = curl_easy_init ();
294 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world"); 299 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world");
295 curl_easy_setopt (c, CURLOPT_PORT, (long)port); 300 curl_easy_setopt (c, CURLOPT_PORT, (long) port);
296 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 301 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
297 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 302 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
298 pd = make_form (); 303 pd = make_form ();
@@ -309,15 +314,15 @@ testMultithreadedPost ()
309 * crashes on my system! */ 314 * crashes on my system! */
310 curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); 315 curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L);
311 if (CURLE_OK != (errornum = curl_easy_perform (c))) 316 if (CURLE_OK != (errornum = curl_easy_perform (c)))
312 { 317 {
313 fprintf (stderr, 318 fprintf (stderr,
314 "curl_easy_perform failed: `%s'\n", 319 "curl_easy_perform failed: `%s'\n",
315 curl_easy_strerror (errornum)); 320 curl_easy_strerror (errornum));
316 curl_easy_cleanup (c); 321 curl_easy_cleanup (c);
317 curl_formfree (pd); 322 curl_formfree (pd);
318 MHD_stop_daemon (d); 323 MHD_stop_daemon (d);
319 return 32; 324 return 32;
320 } 325 }
321 curl_easy_cleanup (c); 326 curl_easy_cleanup (c);
322 curl_formfree (pd); 327 curl_formfree (pd);
323 MHD_stop_daemon (d); 328 MHD_stop_daemon (d);
@@ -342,11 +347,11 @@ testMultithreadedPoolPost ()
342 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) 347 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
343 port = 0; 348 port = 0;
344 else 349 else
345 { 350 {
346 port = 1391; 351 port = 1391;
347 if (oneone) 352 if (oneone)
348 port += 10; 353 port += 10;
349 } 354 }
350 355
351 cbc.buf = buf; 356 cbc.buf = buf;
352 cbc.size = 2048; 357 cbc.size = 2048;
@@ -354,21 +359,23 @@ testMultithreadedPoolPost ()
354 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, 359 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG,
355 port, NULL, NULL, &ahc_echo, NULL, 360 port, NULL, NULL, &ahc_echo, NULL,
356 MHD_OPTION_THREAD_POOL_SIZE, CPU_COUNT, 361 MHD_OPTION_THREAD_POOL_SIZE, CPU_COUNT,
357 MHD_OPTION_NOTIFY_COMPLETED, &completed_cb, NULL, 362 MHD_OPTION_NOTIFY_COMPLETED, &completed_cb, NULL,
358 MHD_OPTION_END); 363 MHD_OPTION_END);
359 if (d == NULL) 364 if (d == NULL)
360 return 16; 365 return 16;
361 if (0 == port) 366 if (0 == port)
367 {
368 const union MHD_DaemonInfo *dinfo;
369 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
370 if ((NULL == dinfo) ||(0 == dinfo->port) )
362 { 371 {
363 const union MHD_DaemonInfo *dinfo; 372 MHD_stop_daemon (d); return 32;
364 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
365 if (NULL == dinfo || 0 == dinfo->port)
366 { MHD_stop_daemon (d); return 32; }
367 port = (int)dinfo->port;
368 } 373 }
374 port = (int) dinfo->port;
375 }
369 c = curl_easy_init (); 376 c = curl_easy_init ();
370 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world"); 377 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world");
371 curl_easy_setopt (c, CURLOPT_PORT, (long)port); 378 curl_easy_setopt (c, CURLOPT_PORT, (long) port);
372 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 379 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
373 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 380 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
374 pd = make_form (); 381 pd = make_form ();
@@ -385,15 +392,15 @@ testMultithreadedPoolPost ()
385 * crashes on my system! */ 392 * crashes on my system! */
386 curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); 393 curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L);
387 if (CURLE_OK != (errornum = curl_easy_perform (c))) 394 if (CURLE_OK != (errornum = curl_easy_perform (c)))
388 { 395 {
389 fprintf (stderr, 396 fprintf (stderr,
390 "curl_easy_perform failed: `%s'\n", 397 "curl_easy_perform failed: `%s'\n",
391 curl_easy_strerror (errornum)); 398 curl_easy_strerror (errornum));
392 curl_easy_cleanup (c); 399 curl_easy_cleanup (c);
393 curl_formfree (pd); 400 curl_formfree (pd);
394 MHD_stop_daemon (d); 401 MHD_stop_daemon (d);
395 return 32; 402 return 32;
396 } 403 }
397 curl_easy_cleanup (c); 404 curl_easy_cleanup (c);
398 curl_formfree (pd); 405 curl_formfree (pd);
399 MHD_stop_daemon (d); 406 MHD_stop_daemon (d);
@@ -432,11 +439,11 @@ testExternalPost ()
432 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) 439 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
433 port = 0; 440 port = 0;
434 else 441 else
435 { 442 {
436 port = 1392; 443 port = 1392;
437 if (oneone) 444 if (oneone)
438 port += 10; 445 port += 10;
439 } 446 }
440 447
441 multi = NULL; 448 multi = NULL;
442 cbc.buf = buf; 449 cbc.buf = buf;
@@ -444,21 +451,23 @@ testExternalPost ()
444 cbc.pos = 0; 451 cbc.pos = 0;
445 d = MHD_start_daemon (MHD_USE_ERROR_LOG, 452 d = MHD_start_daemon (MHD_USE_ERROR_LOG,
446 port, NULL, NULL, &ahc_echo, NULL, 453 port, NULL, NULL, &ahc_echo, NULL,
447 MHD_OPTION_NOTIFY_COMPLETED, &completed_cb, NULL, 454 MHD_OPTION_NOTIFY_COMPLETED, &completed_cb, NULL,
448 MHD_OPTION_END); 455 MHD_OPTION_END);
449 if (d == NULL) 456 if (d == NULL)
450 return 256; 457 return 256;
451 if (0 == port) 458 if (0 == port)
459 {
460 const union MHD_DaemonInfo *dinfo;
461 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
462 if ((NULL == dinfo) ||(0 == dinfo->port) )
452 { 463 {
453 const union MHD_DaemonInfo *dinfo; 464 MHD_stop_daemon (d); return 32;
454 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
455 if (NULL == dinfo || 0 == dinfo->port)
456 { MHD_stop_daemon (d); return 32; }
457 port = (int)dinfo->port;
458 } 465 }
466 port = (int) dinfo->port;
467 }
459 c = curl_easy_init (); 468 c = curl_easy_init ();
460 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world"); 469 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world");
461 curl_easy_setopt (c, CURLOPT_PORT, (long)port); 470 curl_easy_setopt (c, CURLOPT_PORT, (long) port);
462 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 471 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
463 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 472 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
464 pd = make_form (); 473 pd = make_form ();
@@ -478,91 +487,93 @@ testExternalPost ()
478 487
479 multi = curl_multi_init (); 488 multi = curl_multi_init ();
480 if (multi == NULL) 489 if (multi == NULL)
490 {
491 curl_easy_cleanup (c);
492 curl_formfree (pd);
493 MHD_stop_daemon (d);
494 return 512;
495 }
496 mret = curl_multi_add_handle (multi, c);
497 if (mret != CURLM_OK)
498 {
499 curl_multi_cleanup (multi);
500 curl_formfree (pd);
501 curl_easy_cleanup (c);
502 MHD_stop_daemon (d);
503 return 1024;
504 }
505 start = time (NULL);
506 while ((time (NULL) - start < 5) && (multi != NULL))
507 {
508 maxsock = MHD_INVALID_SOCKET;
509 maxposixs = -1;
510 FD_ZERO (&rs);
511 FD_ZERO (&ws);
512 FD_ZERO (&es);
513 curl_multi_perform (multi, &running);
514 mret = curl_multi_fdset (multi, &rs, &ws, &es, &maxposixs);
515 if (mret != CURLM_OK)
481 { 516 {
517 curl_multi_remove_handle (multi, c);
518 curl_multi_cleanup (multi);
482 curl_easy_cleanup (c); 519 curl_easy_cleanup (c);
483 curl_formfree (pd);
484 MHD_stop_daemon (d); 520 MHD_stop_daemon (d);
485 return 512; 521 curl_formfree (pd);
522 return 2048;
486 } 523 }
487 mret = curl_multi_add_handle (multi, c); 524 if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &maxsock))
488 if (mret != CURLM_OK)
489 { 525 {
526 curl_multi_remove_handle (multi, c);
490 curl_multi_cleanup (multi); 527 curl_multi_cleanup (multi);
491 curl_formfree (pd);
492 curl_easy_cleanup (c); 528 curl_easy_cleanup (c);
529 curl_formfree (pd);
493 MHD_stop_daemon (d); 530 MHD_stop_daemon (d);
494 return 1024; 531 return 4096;
495 } 532 }
496 start = time (NULL); 533 tv.tv_sec = 0;
497 while ((time (NULL) - start < 5) && (multi != NULL)) 534 tv.tv_usec = 1000;
535 if (-1 == select (maxposixs + 1, &rs, &ws, &es, &tv))
498 { 536 {
499 maxsock = MHD_INVALID_SOCKET;
500 maxposixs = -1;
501 FD_ZERO (&rs);
502 FD_ZERO (&ws);
503 FD_ZERO (&es);
504 curl_multi_perform (multi, &running);
505 mret = curl_multi_fdset (multi, &rs, &ws, &es, &maxposixs);
506 if (mret != CURLM_OK)
507 {
508 curl_multi_remove_handle (multi, c);
509 curl_multi_cleanup (multi);
510 curl_easy_cleanup (c);
511 MHD_stop_daemon (d);
512 curl_formfree (pd);
513 return 2048;
514 }
515 if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &maxsock))
516 {
517 curl_multi_remove_handle (multi, c);
518 curl_multi_cleanup (multi);
519 curl_easy_cleanup (c);
520 curl_formfree (pd);
521 MHD_stop_daemon (d);
522 return 4096;
523 }
524 tv.tv_sec = 0;
525 tv.tv_usec = 1000;
526 if (-1 == select (maxposixs + 1, &rs, &ws, &es, &tv))
527 {
528#ifdef MHD_POSIX_SOCKETS 537#ifdef MHD_POSIX_SOCKETS
529 if (EINTR != errno) 538 if (EINTR != errno)
530 abort (); 539 abort ();
531#else 540#else
532 if (WSAEINVAL != WSAGetLastError() || 0 != rs.fd_count || 0 != ws.fd_count || 0 != es.fd_count) 541 if ((WSAEINVAL != WSAGetLastError ()) ||(0 != rs.fd_count) ||(0 !=
533 abort (); 542 ws.fd_count)
534 Sleep (1000); 543 ||(0 != es.fd_count) )
544 abort ();
545 Sleep (1000);
535#endif 546#endif
536 }
537 curl_multi_perform (multi, &running);
538 if (running == 0)
539 {
540 msg = curl_multi_info_read (multi, &running);
541 if (msg == NULL)
542 break;
543 if (msg->msg == CURLMSG_DONE)
544 {
545 if (msg->data.result != CURLE_OK)
546 printf ("%s failed at %s:%d: `%s'\n",
547 "curl_multi_perform",
548 __FILE__,
549 __LINE__,
550 curl_easy_strerror (msg->data.result));
551 curl_multi_remove_handle (multi, c);
552 curl_multi_cleanup (multi);
553 curl_easy_cleanup (c);
554 c = NULL;
555 multi = NULL;
556 }
557 }
558 MHD_run (d);
559 } 547 }
560 if (multi != NULL) 548 curl_multi_perform (multi, &running);
549 if (running == 0)
561 { 550 {
562 curl_multi_remove_handle (multi, c); 551 msg = curl_multi_info_read (multi, &running);
563 curl_easy_cleanup (c); 552 if (msg == NULL)
564 curl_multi_cleanup (multi); 553 break;
554 if (msg->msg == CURLMSG_DONE)
555 {
556 if (msg->data.result != CURLE_OK)
557 printf ("%s failed at %s:%d: `%s'\n",
558 "curl_multi_perform",
559 __FILE__,
560 __LINE__,
561 curl_easy_strerror (msg->data.result));
562 curl_multi_remove_handle (multi, c);
563 curl_multi_cleanup (multi);
564 curl_easy_cleanup (c);
565 c = NULL;
566 multi = NULL;
567 }
565 } 568 }
569 MHD_run (d);
570 }
571 if (multi != NULL)
572 {
573 curl_multi_remove_handle (multi, c);
574 curl_easy_cleanup (c);
575 curl_multi_cleanup (multi);
576 }
566 curl_formfree (pd); 577 curl_formfree (pd);
567 MHD_stop_daemon (d); 578 MHD_stop_daemon (d);
568 if (cbc.pos != strlen ("/hello_world")) 579 if (cbc.pos != strlen ("/hello_world"))
@@ -577,7 +588,7 @@ int
577main (int argc, char *const *argv) 588main (int argc, char *const *argv)
578{ 589{
579 unsigned int errorCount = 0; 590 unsigned int errorCount = 0;
580 (void)argc; /* Unused. Silent compiler warning. */ 591 (void) argc; /* Unused. Silent compiler warning. */
581 592
582#ifdef MHD_HTTPS_REQUIRE_GRYPT 593#ifdef MHD_HTTPS_REQUIRE_GRYPT
583#ifdef HAVE_GCRYPT_H 594#ifdef HAVE_GCRYPT_H
@@ -587,17 +598,17 @@ main (int argc, char *const *argv)
587#endif 598#endif
588#endif 599#endif
589#endif /* MHD_HTTPS_REQUIRE_GRYPT */ 600#endif /* MHD_HTTPS_REQUIRE_GRYPT */
590 if (NULL == argv || 0 == argv[0]) 601 if ((NULL == argv)||(0 == argv[0]))
591 return 99; 602 return 99;
592 oneone = has_in_name (argv[0], "11"); 603 oneone = has_in_name (argv[0], "11");
593 if (0 != curl_global_init (CURL_GLOBAL_WIN32)) 604 if (0 != curl_global_init (CURL_GLOBAL_WIN32))
594 return 2; 605 return 2;
595 if (MHD_YES == MHD_is_feature_supported(MHD_FEATURE_THREADS)) 606 if (MHD_YES == MHD_is_feature_supported (MHD_FEATURE_THREADS))
596 { 607 {
597 errorCount += testInternalPost (); 608 errorCount += testInternalPost ();
598 errorCount += testMultithreadedPost (); 609 errorCount += testMultithreadedPost ();
599 errorCount += testMultithreadedPoolPost (); 610 errorCount += testMultithreadedPoolPost ();
600 } 611 }
601 errorCount += testExternalPost (); 612 errorCount += testExternalPost ();
602 if (errorCount != 0) 613 if (errorCount != 0)
603 fprintf (stderr, "Error (code: %u)\n", errorCount); 614 fprintf (stderr, "Error (code: %u)\n", errorCount);