diff options
Diffstat (limited to 'src/testcurl/test_process_headers.c')
-rw-r--r-- | src/testcurl/test_process_headers.c | 325 |
1 files changed, 168 insertions, 157 deletions
diff --git a/src/testcurl/test_process_headers.c b/src/testcurl/test_process_headers.c index a1237c78..a2d7485b 100644 --- a/src/testcurl/test_process_headers.c +++ b/src/testcurl/test_process_headers.c | |||
@@ -1,4 +1,3 @@ | |||
1 | |||
2 | /* | 1 | /* |
3 | This file is part of libmicrohttpd | 2 | This file is part of libmicrohttpd |
4 | Copyright (C) 2007 Christian Grothoff | 3 | Copyright (C) 2007 Christian Grothoff |
@@ -38,10 +37,10 @@ | |||
38 | #include <unistd.h> | 37 | #include <unistd.h> |
39 | #endif | 38 | #endif |
40 | 39 | ||
41 | #if defined(CPU_COUNT) && (CPU_COUNT+0) < 2 | 40 | #if defined(CPU_COUNT) && (CPU_COUNT + 0) < 2 |
42 | #undef CPU_COUNT | 41 | #undef CPU_COUNT |
43 | #endif | 42 | #endif |
44 | #if !defined(CPU_COUNT) | 43 | #if ! defined(CPU_COUNT) |
45 | #define CPU_COUNT 2 | 44 | #define CPU_COUNT 2 |
46 | #endif | 45 | #endif |
47 | 46 | ||
@@ -70,11 +69,12 @@ static int | |||
70 | kv_cb (void *cls, enum MHD_ValueKind kind, const char *key, const char *value) | 69 | kv_cb (void *cls, enum MHD_ValueKind kind, const char *key, const char *value) |
71 | { | 70 | { |
72 | if ((0 == strcmp (key, MHD_HTTP_HEADER_HOST)) && | 71 | if ((0 == strcmp (key, MHD_HTTP_HEADER_HOST)) && |
73 | (0 == strncmp (value, "127.0.0.1", strlen("127.0.0.1"))) && (kind == MHD_HEADER_KIND)) | 72 | (0 == strncmp (value, "127.0.0.1", strlen ("127.0.0.1"))) && (kind == |
74 | { | 73 | MHD_HEADER_KIND)) |
75 | *((int *) cls) = 1; | 74 | { |
76 | return MHD_NO; | 75 | *((int *) cls) = 1; |
77 | } | 76 | return MHD_NO; |
77 | } | ||
78 | return MHD_YES; | 78 | return MHD_YES; |
79 | } | 79 | } |
80 | 80 | ||
@@ -92,15 +92,15 @@ ahc_echo (void *cls, | |||
92 | struct MHD_Response *response; | 92 | struct MHD_Response *response; |
93 | int ret; | 93 | int ret; |
94 | const char *hdr; | 94 | const char *hdr; |
95 | (void)version;(void)upload_data;(void)upload_data_size; /* Unused. Silent compiler warning. */ | 95 | (void) version; (void) upload_data; (void) upload_data_size; /* Unused. Silent compiler warning. */ |
96 | 96 | ||
97 | if (0 != strcmp (me, method)) | 97 | if (0 != strcmp (me, method)) |
98 | return MHD_NO; /* unexpected method */ | 98 | return MHD_NO; /* unexpected method */ |
99 | if (&ptr != *unused) | 99 | if (&ptr != *unused) |
100 | { | 100 | { |
101 | *unused = &ptr; | 101 | *unused = &ptr; |
102 | return MHD_YES; | 102 | return MHD_YES; |
103 | } | 103 | } |
104 | *unused = NULL; | 104 | *unused = NULL; |
105 | ret = 0; | 105 | ret = 0; |
106 | MHD_get_connection_values (connection, MHD_HEADER_KIND, &kv_cb, &ret); | 106 | MHD_get_connection_values (connection, MHD_HEADER_KIND, &kv_cb, &ret); |
@@ -115,7 +115,7 @@ ahc_echo (void *cls, | |||
115 | abort (); | 115 | abort (); |
116 | hdr = MHD_lookup_connection_value (connection, | 116 | hdr = MHD_lookup_connection_value (connection, |
117 | MHD_HEADER_KIND, MHD_HTTP_HEADER_HOST); | 117 | MHD_HEADER_KIND, MHD_HTTP_HEADER_HOST); |
118 | if ((hdr == NULL) || (0 != strncmp (hdr, "127.0.0.1", strlen("127.0.0.1")))) | 118 | if ((hdr == NULL) || (0 != strncmp (hdr, "127.0.0.1", strlen ("127.0.0.1")))) |
119 | abort (); | 119 | abort (); |
120 | MHD_set_connection_value (connection, | 120 | MHD_set_connection_value (connection, |
121 | MHD_HEADER_KIND, "FakeHeader", "NowPresent"); | 121 | MHD_HEADER_KIND, "FakeHeader", "NowPresent"); |
@@ -125,8 +125,8 @@ ahc_echo (void *cls, | |||
125 | abort (); | 125 | abort (); |
126 | 126 | ||
127 | response = MHD_create_response_from_buffer (strlen (url), | 127 | response = MHD_create_response_from_buffer (strlen (url), |
128 | (void *) url, | 128 | (void *) url, |
129 | MHD_RESPMEM_MUST_COPY); | 129 | MHD_RESPMEM_MUST_COPY); |
130 | if (NULL == response) | 130 | if (NULL == response) |
131 | abort (); | 131 | abort (); |
132 | MHD_add_response_header (response, "MyHeader", "MyValue"); | 132 | MHD_add_response_header (response, "MyHeader", "MyValue"); |
@@ -162,11 +162,11 @@ testInternalGet () | |||
162 | if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) | 162 | if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) |
163 | port = 0; | 163 | port = 0; |
164 | else | 164 | else |
165 | { | 165 | { |
166 | port = 1420; | 166 | port = 1420; |
167 | if (oneone) | 167 | if (oneone) |
168 | port += 10; | 168 | port += 10; |
169 | } | 169 | } |
170 | 170 | ||
171 | cbc.buf = buf; | 171 | cbc.buf = buf; |
172 | cbc.size = 2048; | 172 | cbc.size = 2048; |
@@ -176,16 +176,18 @@ testInternalGet () | |||
176 | if (d == NULL) | 176 | if (d == NULL) |
177 | return 1; | 177 | return 1; |
178 | if (0 == port) | 178 | if (0 == port) |
179 | { | ||
180 | const union MHD_DaemonInfo *dinfo; | ||
181 | dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); | ||
182 | if ((NULL == dinfo) ||(0 == dinfo->port) ) | ||
179 | { | 183 | { |
180 | const union MHD_DaemonInfo *dinfo; | 184 | MHD_stop_daemon (d); return 32; |
181 | dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); | ||
182 | if (NULL == dinfo || 0 == dinfo->port) | ||
183 | { MHD_stop_daemon (d); return 32; } | ||
184 | port = (int)dinfo->port; | ||
185 | } | 185 | } |
186 | port = (int) dinfo->port; | ||
187 | } | ||
186 | c = curl_easy_init (); | 188 | c = curl_easy_init (); |
187 | curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world"); | 189 | curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world"); |
188 | curl_easy_setopt (c, CURLOPT_PORT, (long)port); | 190 | curl_easy_setopt (c, CURLOPT_PORT, (long) port); |
189 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); | 191 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); |
190 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); | 192 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); |
191 | curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); | 193 | curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); |
@@ -200,14 +202,14 @@ testInternalGet () | |||
200 | crashes on my system! */ | 202 | crashes on my system! */ |
201 | curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); | 203 | curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); |
202 | if (CURLE_OK != (errornum = curl_easy_perform (c))) | 204 | if (CURLE_OK != (errornum = curl_easy_perform (c))) |
203 | { | 205 | { |
204 | fprintf (stderr, | 206 | fprintf (stderr, |
205 | "curl_easy_perform failed: `%s'\n", | 207 | "curl_easy_perform failed: `%s'\n", |
206 | curl_easy_strerror (errornum)); | 208 | curl_easy_strerror (errornum)); |
207 | curl_easy_cleanup (c); | 209 | curl_easy_cleanup (c); |
208 | MHD_stop_daemon (d); | 210 | MHD_stop_daemon (d); |
209 | return 2; | 211 | return 2; |
210 | } | 212 | } |
211 | curl_easy_cleanup (c); | 213 | curl_easy_cleanup (c); |
212 | MHD_stop_daemon (d); | 214 | MHD_stop_daemon (d); |
213 | if (cbc.pos != strlen ("/hello_world")) | 215 | if (cbc.pos != strlen ("/hello_world")) |
@@ -230,30 +232,33 @@ testMultithreadedGet () | |||
230 | if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) | 232 | if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) |
231 | port = 0; | 233 | port = 0; |
232 | else | 234 | else |
233 | { | 235 | { |
234 | port = 1421; | 236 | port = 1421; |
235 | if (oneone) | 237 | if (oneone) |
236 | port += 10; | 238 | port += 10; |
237 | } | 239 | } |
238 | 240 | ||
239 | cbc.buf = buf; | 241 | cbc.buf = buf; |
240 | cbc.size = 2048; | 242 | cbc.size = 2048; |
241 | cbc.pos = 0; | 243 | cbc.pos = 0; |
242 | d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, | 244 | d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION |
245 | | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, | ||
243 | port, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); | 246 | port, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); |
244 | if (d == NULL) | 247 | if (d == NULL) |
245 | return 16; | 248 | return 16; |
246 | if (0 == port) | 249 | if (0 == port) |
250 | { | ||
251 | const union MHD_DaemonInfo *dinfo; | ||
252 | dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); | ||
253 | if ((NULL == dinfo) ||(0 == dinfo->port) ) | ||
247 | { | 254 | { |
248 | const union MHD_DaemonInfo *dinfo; | 255 | MHD_stop_daemon (d); return 32; |
249 | dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); | ||
250 | if (NULL == dinfo || 0 == dinfo->port) | ||
251 | { MHD_stop_daemon (d); return 32; } | ||
252 | port = (int)dinfo->port; | ||
253 | } | 256 | } |
257 | port = (int) dinfo->port; | ||
258 | } | ||
254 | c = curl_easy_init (); | 259 | c = curl_easy_init (); |
255 | curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world"); | 260 | curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world"); |
256 | curl_easy_setopt (c, CURLOPT_PORT, (long)port); | 261 | curl_easy_setopt (c, CURLOPT_PORT, (long) port); |
257 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); | 262 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); |
258 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); | 263 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); |
259 | curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); | 264 | curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); |
@@ -268,14 +273,14 @@ testMultithreadedGet () | |||
268 | crashes on my system! */ | 273 | crashes on my system! */ |
269 | curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); | 274 | curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); |
270 | if (CURLE_OK != (errornum = curl_easy_perform (c))) | 275 | if (CURLE_OK != (errornum = curl_easy_perform (c))) |
271 | { | 276 | { |
272 | fprintf (stderr, | 277 | fprintf (stderr, |
273 | "curl_easy_perform failed: `%s'\n", | 278 | "curl_easy_perform failed: `%s'\n", |
274 | curl_easy_strerror (errornum)); | 279 | curl_easy_strerror (errornum)); |
275 | curl_easy_cleanup (c); | 280 | curl_easy_cleanup (c); |
276 | MHD_stop_daemon (d); | 281 | MHD_stop_daemon (d); |
277 | return 32; | 282 | return 32; |
278 | } | 283 | } |
279 | curl_easy_cleanup (c); | 284 | curl_easy_cleanup (c); |
280 | MHD_stop_daemon (d); | 285 | MHD_stop_daemon (d); |
281 | if (cbc.pos != strlen ("/hello_world")) | 286 | if (cbc.pos != strlen ("/hello_world")) |
@@ -298,11 +303,11 @@ testMultithreadedPoolGet () | |||
298 | if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) | 303 | if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) |
299 | port = 0; | 304 | port = 0; |
300 | else | 305 | else |
301 | { | 306 | { |
302 | port = 1422; | 307 | port = 1422; |
303 | if (oneone) | 308 | if (oneone) |
304 | port += 10; | 309 | port += 10; |
305 | } | 310 | } |
306 | 311 | ||
307 | cbc.buf = buf; | 312 | cbc.buf = buf; |
308 | cbc.size = 2048; | 313 | cbc.size = 2048; |
@@ -313,16 +318,18 @@ testMultithreadedPoolGet () | |||
313 | if (d == NULL) | 318 | if (d == NULL) |
314 | return 16; | 319 | return 16; |
315 | if (0 == port) | 320 | if (0 == port) |
321 | { | ||
322 | const union MHD_DaemonInfo *dinfo; | ||
323 | dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); | ||
324 | if ((NULL == dinfo) ||(0 == dinfo->port) ) | ||
316 | { | 325 | { |
317 | const union MHD_DaemonInfo *dinfo; | 326 | MHD_stop_daemon (d); return 32; |
318 | dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); | ||
319 | if (NULL == dinfo || 0 == dinfo->port) | ||
320 | { MHD_stop_daemon (d); return 32; } | ||
321 | port = (int)dinfo->port; | ||
322 | } | 327 | } |
328 | port = (int) dinfo->port; | ||
329 | } | ||
323 | c = curl_easy_init (); | 330 | c = curl_easy_init (); |
324 | curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world"); | 331 | curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world"); |
325 | curl_easy_setopt (c, CURLOPT_PORT, (long)port); | 332 | curl_easy_setopt (c, CURLOPT_PORT, (long) port); |
326 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); | 333 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); |
327 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); | 334 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); |
328 | curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); | 335 | curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); |
@@ -337,14 +344,14 @@ testMultithreadedPoolGet () | |||
337 | crashes on my system! */ | 344 | crashes on my system! */ |
338 | curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); | 345 | curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); |
339 | if (CURLE_OK != (errornum = curl_easy_perform (c))) | 346 | if (CURLE_OK != (errornum = curl_easy_perform (c))) |
340 | { | 347 | { |
341 | fprintf (stderr, | 348 | fprintf (stderr, |
342 | "curl_easy_perform failed: `%s'\n", | 349 | "curl_easy_perform failed: `%s'\n", |
343 | curl_easy_strerror (errornum)); | 350 | curl_easy_strerror (errornum)); |
344 | curl_easy_cleanup (c); | 351 | curl_easy_cleanup (c); |
345 | MHD_stop_daemon (d); | 352 | MHD_stop_daemon (d); |
346 | return 32; | 353 | return 32; |
347 | } | 354 | } |
348 | curl_easy_cleanup (c); | 355 | curl_easy_cleanup (c); |
349 | MHD_stop_daemon (d); | 356 | MHD_stop_daemon (d); |
350 | if (cbc.pos != strlen ("/hello_world")) | 357 | if (cbc.pos != strlen ("/hello_world")) |
@@ -381,11 +388,11 @@ testExternalGet () | |||
381 | if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) | 388 | if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) |
382 | port = 0; | 389 | port = 0; |
383 | else | 390 | else |
384 | { | 391 | { |
385 | port = 1423; | 392 | port = 1423; |
386 | if (oneone) | 393 | if (oneone) |
387 | port += 10; | 394 | port += 10; |
388 | } | 395 | } |
389 | 396 | ||
390 | multi = NULL; | 397 | multi = NULL; |
391 | cbc.buf = buf; | 398 | cbc.buf = buf; |
@@ -396,16 +403,18 @@ testExternalGet () | |||
396 | if (d == NULL) | 403 | if (d == NULL) |
397 | return 256; | 404 | return 256; |
398 | if (0 == port) | 405 | if (0 == port) |
406 | { | ||
407 | const union MHD_DaemonInfo *dinfo; | ||
408 | dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); | ||
409 | if ((NULL == dinfo) ||(0 == dinfo->port) ) | ||
399 | { | 410 | { |
400 | const union MHD_DaemonInfo *dinfo; | 411 | MHD_stop_daemon (d); return 32; |
401 | dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); | ||
402 | if (NULL == dinfo || 0 == dinfo->port) | ||
403 | { MHD_stop_daemon (d); return 32; } | ||
404 | port = (int)dinfo->port; | ||
405 | } | 412 | } |
413 | port = (int) dinfo->port; | ||
414 | } | ||
406 | c = curl_easy_init (); | 415 | c = curl_easy_init (); |
407 | curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world"); | 416 | curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world"); |
408 | curl_easy_setopt (c, CURLOPT_PORT, (long)port); | 417 | curl_easy_setopt (c, CURLOPT_PORT, (long) port); |
409 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); | 418 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); |
410 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); | 419 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); |
411 | curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); | 420 | curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); |
@@ -423,86 +432,88 @@ testExternalGet () | |||
423 | 432 | ||
424 | multi = curl_multi_init (); | 433 | multi = curl_multi_init (); |
425 | if (multi == NULL) | 434 | if (multi == NULL) |
435 | { | ||
436 | curl_easy_cleanup (c); | ||
437 | MHD_stop_daemon (d); | ||
438 | return 512; | ||
439 | } | ||
440 | mret = curl_multi_add_handle (multi, c); | ||
441 | if (mret != CURLM_OK) | ||
442 | { | ||
443 | curl_multi_cleanup (multi); | ||
444 | curl_easy_cleanup (c); | ||
445 | MHD_stop_daemon (d); | ||
446 | return 1024; | ||
447 | } | ||
448 | start = time (NULL); | ||
449 | while ((time (NULL) - start < 5) && (multi != NULL)) | ||
450 | { | ||
451 | maxsock = MHD_INVALID_SOCKET; | ||
452 | maxposixs = -1; | ||
453 | FD_ZERO (&rs); | ||
454 | FD_ZERO (&ws); | ||
455 | FD_ZERO (&es); | ||
456 | curl_multi_perform (multi, &running); | ||
457 | mret = curl_multi_fdset (multi, &rs, &ws, &es, &maxposixs); | ||
458 | if (mret != CURLM_OK) | ||
426 | { | 459 | { |
460 | curl_multi_remove_handle (multi, c); | ||
461 | curl_multi_cleanup (multi); | ||
427 | curl_easy_cleanup (c); | 462 | curl_easy_cleanup (c); |
428 | MHD_stop_daemon (d); | 463 | MHD_stop_daemon (d); |
429 | return 512; | 464 | return 2048; |
430 | } | 465 | } |
431 | mret = curl_multi_add_handle (multi, c); | 466 | if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &maxsock)) |
432 | if (mret != CURLM_OK) | ||
433 | { | 467 | { |
468 | curl_multi_remove_handle (multi, c); | ||
434 | curl_multi_cleanup (multi); | 469 | curl_multi_cleanup (multi); |
435 | curl_easy_cleanup (c); | 470 | curl_easy_cleanup (c); |
436 | MHD_stop_daemon (d); | 471 | MHD_stop_daemon (d); |
437 | return 1024; | 472 | return 4096; |
438 | } | 473 | } |
439 | start = time (NULL); | 474 | tv.tv_sec = 0; |
440 | while ((time (NULL) - start < 5) && (multi != NULL)) | 475 | tv.tv_usec = 1000; |
476 | if (-1 == select (maxposixs + 1, &rs, &ws, &es, &tv)) | ||
441 | { | 477 | { |
442 | maxsock = MHD_INVALID_SOCKET; | ||
443 | maxposixs = -1; | ||
444 | FD_ZERO (&rs); | ||
445 | FD_ZERO (&ws); | ||
446 | FD_ZERO (&es); | ||
447 | curl_multi_perform (multi, &running); | ||
448 | mret = curl_multi_fdset (multi, &rs, &ws, &es, &maxposixs); | ||
449 | if (mret != CURLM_OK) | ||
450 | { | ||
451 | curl_multi_remove_handle (multi, c); | ||
452 | curl_multi_cleanup (multi); | ||
453 | curl_easy_cleanup (c); | ||
454 | MHD_stop_daemon (d); | ||
455 | return 2048; | ||
456 | } | ||
457 | if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &maxsock)) | ||
458 | { | ||
459 | curl_multi_remove_handle (multi, c); | ||
460 | curl_multi_cleanup (multi); | ||
461 | curl_easy_cleanup (c); | ||
462 | MHD_stop_daemon (d); | ||
463 | return 4096; | ||
464 | } | ||
465 | tv.tv_sec = 0; | ||
466 | tv.tv_usec = 1000; | ||
467 | if (-1 == select (maxposixs + 1, &rs, &ws, &es, &tv)) | ||
468 | { | ||
469 | #ifdef MHD_POSIX_SOCKETS | 478 | #ifdef MHD_POSIX_SOCKETS |
470 | if (EINTR != errno) | 479 | if (EINTR != errno) |
471 | abort (); | 480 | abort (); |
472 | #else | 481 | #else |
473 | if (WSAEINVAL != WSAGetLastError() || 0 != rs.fd_count || 0 != ws.fd_count || 0 != es.fd_count) | 482 | if ((WSAEINVAL != WSAGetLastError ()) ||(0 != rs.fd_count) ||(0 != |
474 | abort (); | 483 | ws.fd_count) |
475 | Sleep (1000); | 484 | ||(0 != es.fd_count) ) |
485 | abort (); | ||
486 | Sleep (1000); | ||
476 | #endif | 487 | #endif |
477 | } | ||
478 | curl_multi_perform (multi, &running); | ||
479 | if (running == 0) | ||
480 | { | ||
481 | msg = curl_multi_info_read (multi, &running); | ||
482 | if (msg == NULL) | ||
483 | break; | ||
484 | if (msg->msg == CURLMSG_DONE) | ||
485 | { | ||
486 | if (msg->data.result != CURLE_OK) | ||
487 | printf ("%s failed at %s:%d: `%s'\n", | ||
488 | "curl_multi_perform", | ||
489 | __FILE__, | ||
490 | __LINE__, curl_easy_strerror (msg->data.result)); | ||
491 | curl_multi_remove_handle (multi, c); | ||
492 | curl_multi_cleanup (multi); | ||
493 | curl_easy_cleanup (c); | ||
494 | c = NULL; | ||
495 | multi = NULL; | ||
496 | } | ||
497 | } | ||
498 | MHD_run (d); | ||
499 | } | 488 | } |
500 | if (multi != NULL) | 489 | curl_multi_perform (multi, &running); |
490 | if (running == 0) | ||
501 | { | 491 | { |
502 | curl_multi_remove_handle (multi, c); | 492 | msg = curl_multi_info_read (multi, &running); |
503 | curl_easy_cleanup (c); | 493 | if (msg == NULL) |
504 | curl_multi_cleanup (multi); | 494 | break; |
495 | if (msg->msg == CURLMSG_DONE) | ||
496 | { | ||
497 | if (msg->data.result != CURLE_OK) | ||
498 | printf ("%s failed at %s:%d: `%s'\n", | ||
499 | "curl_multi_perform", | ||
500 | __FILE__, | ||
501 | __LINE__, curl_easy_strerror (msg->data.result)); | ||
502 | curl_multi_remove_handle (multi, c); | ||
503 | curl_multi_cleanup (multi); | ||
504 | curl_easy_cleanup (c); | ||
505 | c = NULL; | ||
506 | multi = NULL; | ||
507 | } | ||
505 | } | 508 | } |
509 | MHD_run (d); | ||
510 | } | ||
511 | if (multi != NULL) | ||
512 | { | ||
513 | curl_multi_remove_handle (multi, c); | ||
514 | curl_easy_cleanup (c); | ||
515 | curl_multi_cleanup (multi); | ||
516 | } | ||
506 | MHD_stop_daemon (d); | 517 | MHD_stop_daemon (d); |
507 | if (cbc.pos != strlen ("/hello_world")) | 518 | if (cbc.pos != strlen ("/hello_world")) |
508 | return 8192; | 519 | return 8192; |
@@ -517,17 +528,17 @@ int | |||
517 | main (int argc, char *const *argv) | 528 | main (int argc, char *const *argv) |
518 | { | 529 | { |
519 | unsigned int errorCount = 0; | 530 | unsigned int errorCount = 0; |
520 | (void)argc; /* Unused. Silent compiler warning. */ | 531 | (void) argc; /* Unused. Silent compiler warning. */ |
521 | 532 | ||
522 | if (NULL == argv || 0 == argv[0]) | 533 | if ((NULL == argv)||(0 == argv[0])) |
523 | return 99; | 534 | return 99; |
524 | oneone = has_in_name (argv[0], "11"); | 535 | oneone = has_in_name (argv[0], "11"); |
525 | if (MHD_YES == MHD_is_feature_supported(MHD_FEATURE_THREADS)) | 536 | if (MHD_YES == MHD_is_feature_supported (MHD_FEATURE_THREADS)) |
526 | { | 537 | { |
527 | errorCount += testInternalGet (); | 538 | errorCount += testInternalGet (); |
528 | errorCount += testMultithreadedGet (); | 539 | errorCount += testMultithreadedGet (); |
529 | errorCount += testMultithreadedPoolGet (); | 540 | errorCount += testMultithreadedPoolGet (); |
530 | } | 541 | } |
531 | errorCount += testExternalGet (); | 542 | errorCount += testExternalGet (); |
532 | if (errorCount != 0) | 543 | if (errorCount != 0) |
533 | fprintf (stderr, "Error (code: %u)\n", errorCount); | 544 | fprintf (stderr, "Error (code: %u)\n", errorCount); |