diff options
Diffstat (limited to 'src/testcurl/perf_get_concurrent.c')
-rw-r--r-- | src/testcurl/perf_get_concurrent.c | 368 |
1 files changed, 199 insertions, 169 deletions
diff --git a/src/testcurl/perf_get_concurrent.c b/src/testcurl/perf_get_concurrent.c index 336a1d1e..b4cd6d8d 100644 --- a/src/testcurl/perf_get_concurrent.c +++ b/src/testcurl/perf_get_concurrent.c | |||
@@ -43,10 +43,10 @@ | |||
43 | #include "gauger.h" | 43 | #include "gauger.h" |
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 | ||
@@ -98,8 +98,8 @@ now () | |||
98 | struct timeval tv; | 98 | struct timeval tv; |
99 | 99 | ||
100 | gettimeofday (&tv, NULL); | 100 | gettimeofday (&tv, NULL); |
101 | return (((unsigned long long) tv.tv_sec * 1000LL) + | 101 | return (((unsigned long long) tv.tv_sec * 1000LL) |
102 | ((unsigned long long) tv.tv_usec / 1000LL)); | 102 | + ((unsigned long long) tv.tv_usec / 1000LL)); |
103 | } | 103 | } |
104 | 104 | ||
105 | 105 | ||
@@ -107,7 +107,7 @@ now () | |||
107 | * Start the timer. | 107 | * Start the timer. |
108 | */ | 108 | */ |
109 | static void | 109 | static void |
110 | start_timer() | 110 | start_timer () |
111 | { | 111 | { |
112 | start_time = now (); | 112 | start_time = now (); |
113 | } | 113 | } |
@@ -121,26 +121,27 @@ start_timer() | |||
121 | static void | 121 | static void |
122 | stop (const char *desc) | 122 | stop (const char *desc) |
123 | { | 123 | { |
124 | double rps = ((double) (PAR * ROUNDS * 1000)) / ((double) (now() - start_time)); | 124 | double rps = ((double) (PAR * ROUNDS * 1000)) / ((double) (now () |
125 | - start_time)); | ||
125 | 126 | ||
126 | fprintf (stderr, | 127 | fprintf (stderr, |
127 | "Parallel GETs using %s: %f %s\n", | 128 | "Parallel GETs using %s: %f %s\n", |
128 | desc, | 129 | desc, |
129 | rps, | 130 | rps, |
130 | "requests/s"); | 131 | "requests/s"); |
131 | GAUGER (desc, | 132 | GAUGER (desc, |
132 | "Parallel GETs", | 133 | "Parallel GETs", |
133 | rps, | 134 | rps, |
134 | "requests/s"); | 135 | "requests/s"); |
135 | } | 136 | } |
136 | 137 | ||
137 | 138 | ||
138 | static size_t | 139 | static size_t |
139 | copyBuffer (void *ptr, | 140 | copyBuffer (void *ptr, |
140 | size_t size, size_t nmemb, | 141 | size_t size, size_t nmemb, |
141 | void *ctx) | 142 | void *ctx) |
142 | { | 143 | { |
143 | (void)ptr;(void)ctx; /* Unused. Silent compiler warning. */ | 144 | (void) ptr; (void) ctx; /* Unused. Silent compiler warning. */ |
144 | return size * nmemb; | 145 | return size * nmemb; |
145 | } | 146 | } |
146 | 147 | ||
@@ -157,16 +158,16 @@ ahc_echo (void *cls, | |||
157 | static int ptr; | 158 | static int ptr; |
158 | const char *me = cls; | 159 | const char *me = cls; |
159 | int ret; | 160 | int ret; |
160 | (void)url;(void)version; /* Unused. Silent compiler warning. */ | 161 | (void) url; (void) version; /* Unused. Silent compiler warning. */ |
161 | (void)upload_data;(void)upload_data_size; /* Unused. Silent compiler warning. */ | 162 | (void) upload_data; (void) upload_data_size; /* Unused. Silent compiler warning. */ |
162 | 163 | ||
163 | if (0 != strcmp (me, method)) | 164 | if (0 != strcmp (me, method)) |
164 | return MHD_NO; /* unexpected method */ | 165 | return MHD_NO; /* unexpected method */ |
165 | if (&ptr != *unused) | 166 | if (&ptr != *unused) |
166 | { | 167 | { |
167 | *unused = &ptr; | 168 | *unused = &ptr; |
168 | return MHD_YES; | 169 | return MHD_YES; |
169 | } | 170 | } |
170 | *unused = NULL; | 171 | *unused = NULL; |
171 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); | 172 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); |
172 | if (ret == MHD_NO) | 173 | if (ret == MHD_NO) |
@@ -181,7 +182,7 @@ thread_gets (void *param) | |||
181 | CURL *c; | 182 | CURL *c; |
182 | CURLcode errornum; | 183 | CURLcode errornum; |
183 | unsigned int i; | 184 | unsigned int i; |
184 | char * const url = (char*) param; | 185 | char *const url = (char*) param; |
185 | 186 | ||
186 | c = curl_easy_init (); | 187 | c = curl_easy_init (); |
187 | curl_easy_setopt (c, CURLOPT_URL, url); | 188 | curl_easy_setopt (c, CURLOPT_URL, url); |
@@ -198,17 +199,17 @@ thread_gets (void *param) | |||
198 | setting NOSIGNAL results in really weird | 199 | setting NOSIGNAL results in really weird |
199 | crashes on my system! */ | 200 | crashes on my system! */ |
200 | curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); | 201 | curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); |
201 | for (i=0;i<ROUNDS;i++) | 202 | for (i = 0; i<ROUNDS; i++) |
203 | { | ||
204 | if (CURLE_OK != (errornum = curl_easy_perform (c))) | ||
202 | { | 205 | { |
203 | if (CURLE_OK != (errornum = curl_easy_perform (c))) | 206 | fprintf (stderr, |
204 | { | 207 | "curl_easy_perform failed: `%s'\n", |
205 | fprintf (stderr, | 208 | curl_easy_strerror (errornum)); |
206 | "curl_easy_perform failed: `%s'\n", | 209 | curl_easy_cleanup (c); |
207 | curl_easy_strerror (errornum)); | 210 | return "curl error"; |
208 | curl_easy_cleanup (c); | ||
209 | return "curl error"; | ||
210 | } | ||
211 | } | 211 | } |
212 | } | ||
212 | curl_easy_cleanup (c); | 213 | curl_easy_cleanup (c); |
213 | 214 | ||
214 | return NULL; | 215 | return NULL; |
@@ -216,34 +217,34 @@ thread_gets (void *param) | |||
216 | 217 | ||
217 | 218 | ||
218 | static void * | 219 | static void * |
219 | do_gets (void * param) | 220 | do_gets (void *param) |
220 | { | 221 | { |
221 | int j; | 222 | int j; |
222 | pthread_t par[PAR]; | 223 | pthread_t par[PAR]; |
223 | char url[64]; | 224 | char url[64]; |
224 | int port = (int)(intptr_t)param; | 225 | int port = (int) (intptr_t) param; |
225 | char *err = NULL; | 226 | char *err = NULL; |
226 | 227 | ||
227 | snprintf (url, | 228 | snprintf (url, |
228 | sizeof (url), | 229 | sizeof (url), |
229 | "http://127.0.0.1:%d/hello_world", | 230 | "http://127.0.0.1:%d/hello_world", |
230 | port); | 231 | port); |
231 | for (j=0;j<PAR;j++) | 232 | for (j = 0; j<PAR; j++) |
232 | { | 233 | { |
233 | if (0 != pthread_create(&par[j], NULL, &thread_gets, (void*)url)) | 234 | if (0 != pthread_create (&par[j], NULL, &thread_gets, (void*) url)) |
234 | { | ||
235 | for (j--; j >= 0; j--) | ||
236 | pthread_join(par[j], NULL); | ||
237 | return "pthread_create error"; | ||
238 | } | ||
239 | } | ||
240 | for (j=0;j<PAR;j++) | ||
241 | { | 235 | { |
242 | char *ret_val; | 236 | for (j--; j >= 0; j--) |
243 | if (0 != pthread_join(par[j], (void**)&ret_val) || | 237 | pthread_join (par[j], NULL); |
244 | NULL != ret_val) | 238 | return "pthread_create error"; |
245 | err = ret_val; | ||
246 | } | 239 | } |
240 | } | ||
241 | for (j = 0; j<PAR; j++) | ||
242 | { | ||
243 | char *ret_val; | ||
244 | if ((0 != pthread_join (par[j], (void**) &ret_val)) || | ||
245 | (NULL != ret_val) ) | ||
246 | err = ret_val; | ||
247 | } | ||
247 | signal_done = 1; | 248 | signal_done = 1; |
248 | return err; | 249 | return err; |
249 | } | 250 | } |
@@ -253,38 +254,45 @@ static int | |||
253 | testInternalGet (int port, int poll_flag) | 254 | testInternalGet (int port, int poll_flag) |
254 | { | 255 | { |
255 | struct MHD_Daemon *d; | 256 | struct MHD_Daemon *d; |
256 | const char * const test_desc = ((poll_flag & MHD_USE_AUTO) ? "internal thread with 'auto'" : | 257 | const char *const test_desc = ((poll_flag & MHD_USE_AUTO) ? |
257 | (poll_flag & MHD_USE_POLL) ? "internal thread with poll()" : | 258 | "internal thread with 'auto'" : |
258 | (poll_flag & MHD_USE_EPOLL) ? "internal thread with epoll" : "internal thread with select()"); | 259 | (poll_flag & MHD_USE_POLL) ? |
259 | const char * ret_val; | 260 | "internal thread with poll()" : |
260 | 261 | (poll_flag & MHD_USE_EPOLL) ? | |
261 | if (MHD_NO != MHD_is_feature_supported(MHD_FEATURE_AUTODETECT_BIND_PORT)) | 262 | "internal thread with epoll" : |
263 | "internal thread with select()"); | ||
264 | const char *ret_val; | ||
265 | |||
266 | if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) | ||
262 | port = 0; | 267 | port = 0; |
263 | 268 | ||
264 | signal_done = 0; | 269 | signal_done = 0; |
265 | d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | poll_flag, | 270 | d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG |
271 | | poll_flag, | ||
266 | port, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); | 272 | port, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); |
267 | if (d == NULL) | 273 | if (d == NULL) |
268 | return 1; | 274 | return 1; |
269 | if (0 == port) | 275 | if (0 == port) |
276 | { | ||
277 | const union MHD_DaemonInfo *dinfo; | ||
278 | dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); | ||
279 | if ((NULL == dinfo) ||(0 == dinfo->port) ) | ||
270 | { | 280 | { |
271 | const union MHD_DaemonInfo *dinfo; | 281 | MHD_stop_daemon (d); return 32; |
272 | dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); | ||
273 | if (NULL == dinfo || 0 == dinfo->port) | ||
274 | { MHD_stop_daemon (d); return 32; } | ||
275 | port = (int)dinfo->port; | ||
276 | } | 282 | } |
283 | port = (int) dinfo->port; | ||
284 | } | ||
277 | start_timer (); | 285 | start_timer (); |
278 | ret_val = do_gets ((void*)(intptr_t)port); | 286 | ret_val = do_gets ((void*) (intptr_t) port); |
279 | if (!ret_val) | 287 | if (! ret_val) |
280 | stop (test_desc); | 288 | stop (test_desc); |
281 | MHD_stop_daemon (d); | 289 | MHD_stop_daemon (d); |
282 | if (ret_val) | 290 | if (ret_val) |
283 | { | 291 | { |
284 | fprintf (stderr, | 292 | fprintf (stderr, |
285 | "Error performing %s test: %s\n", test_desc, ret_val); | 293 | "Error performing %s test: %s\n", test_desc, ret_val); |
286 | return 4; | 294 | return 4; |
287 | } | 295 | } |
288 | return 0; | 296 | return 0; |
289 | } | 297 | } |
290 | 298 | ||
@@ -293,39 +301,49 @@ static int | |||
293 | testMultithreadedGet (int port, int poll_flag) | 301 | testMultithreadedGet (int port, int poll_flag) |
294 | { | 302 | { |
295 | struct MHD_Daemon *d; | 303 | struct MHD_Daemon *d; |
296 | const char * const test_desc = ((poll_flag & MHD_USE_AUTO) ? "internal thread with 'auto' and thread per connection" : | 304 | const char *const test_desc = ((poll_flag & MHD_USE_AUTO) ? |
297 | (poll_flag & MHD_USE_POLL) ? "internal thread with poll() and thread per connection" : | 305 | "internal thread with 'auto' and thread per connection" |
298 | (poll_flag & MHD_USE_EPOLL) ? "internal thread with epoll and thread per connection" | 306 | : |
299 | : "internal thread with select() and thread per connection"); | 307 | (poll_flag & MHD_USE_POLL) ? |
300 | const char * ret_val; | 308 | "internal thread with poll() and thread per connection" |
301 | 309 | : | |
302 | if (MHD_NO != MHD_is_feature_supported(MHD_FEATURE_AUTODETECT_BIND_PORT)) | 310 | (poll_flag & MHD_USE_EPOLL) ? |
311 | "internal thread with epoll and thread per connection" | ||
312 | : | ||
313 | "internal thread with select() and thread per connection"); | ||
314 | const char *ret_val; | ||
315 | |||
316 | if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) | ||
303 | port = 0; | 317 | port = 0; |
304 | 318 | ||
305 | signal_done = 0; | 319 | signal_done = 0; |
306 | d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | poll_flag, | 320 | d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION |
321 | | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | ||
322 | | poll_flag, | ||
307 | port, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); | 323 | port, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); |
308 | if (d == NULL) | 324 | if (d == NULL) |
309 | return 16; | 325 | return 16; |
310 | if (0 == port) | 326 | if (0 == port) |
327 | { | ||
328 | const union MHD_DaemonInfo *dinfo; | ||
329 | dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); | ||
330 | if ((NULL == dinfo) ||(0 == dinfo->port) ) | ||
311 | { | 331 | { |
312 | const union MHD_DaemonInfo *dinfo; | 332 | MHD_stop_daemon (d); return 32; |
313 | dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); | ||
314 | if (NULL == dinfo || 0 == dinfo->port) | ||
315 | { MHD_stop_daemon (d); return 32; } | ||
316 | port = (int)dinfo->port; | ||
317 | } | 333 | } |
334 | port = (int) dinfo->port; | ||
335 | } | ||
318 | start_timer (); | 336 | start_timer (); |
319 | ret_val = do_gets ((void*)(intptr_t)port); | 337 | ret_val = do_gets ((void*) (intptr_t) port); |
320 | if (!ret_val) | 338 | if (! ret_val) |
321 | stop (test_desc); | 339 | stop (test_desc); |
322 | MHD_stop_daemon (d); | 340 | MHD_stop_daemon (d); |
323 | if (ret_val) | 341 | if (ret_val) |
324 | { | 342 | { |
325 | fprintf (stderr, | 343 | fprintf (stderr, |
326 | "Error performing %s test: %s\n", test_desc, ret_val); | 344 | "Error performing %s test: %s\n", test_desc, ret_val); |
327 | return 4; | 345 | return 4; |
328 | } | 346 | } |
329 | return 0; | 347 | return 0; |
330 | } | 348 | } |
331 | 349 | ||
@@ -334,39 +352,46 @@ static int | |||
334 | testMultithreadedPoolGet (int port, int poll_flag) | 352 | testMultithreadedPoolGet (int port, int poll_flag) |
335 | { | 353 | { |
336 | struct MHD_Daemon *d; | 354 | struct MHD_Daemon *d; |
337 | const char * const test_desc = ((poll_flag & MHD_USE_AUTO) ? "internal thread pool with 'auto'" : | 355 | const char *const test_desc = ((poll_flag & MHD_USE_AUTO) ? |
338 | (poll_flag & MHD_USE_POLL) ? "internal thread pool with poll()" : | 356 | "internal thread pool with 'auto'" : |
339 | (poll_flag & MHD_USE_EPOLL) ? "internal thread poll with epoll" : "internal thread pool with select()"); | 357 | (poll_flag & MHD_USE_POLL) ? |
340 | const char * ret_val; | 358 | "internal thread pool with poll()" : |
341 | 359 | (poll_flag & MHD_USE_EPOLL) ? | |
342 | if (MHD_NO != MHD_is_feature_supported(MHD_FEATURE_AUTODETECT_BIND_PORT)) | 360 | "internal thread poll with epoll" : |
361 | "internal thread pool with select()"); | ||
362 | const char *ret_val; | ||
363 | |||
364 | if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) | ||
343 | port = 0; | 365 | port = 0; |
344 | 366 | ||
345 | signal_done = 0 ; | 367 | signal_done = 0; |
346 | d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | poll_flag, | 368 | d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG |
369 | | poll_flag, | ||
347 | port, NULL, NULL, &ahc_echo, "GET", | 370 | port, NULL, NULL, &ahc_echo, "GET", |
348 | MHD_OPTION_THREAD_POOL_SIZE, CPU_COUNT, MHD_OPTION_END); | 371 | MHD_OPTION_THREAD_POOL_SIZE, CPU_COUNT, MHD_OPTION_END); |
349 | if (d == NULL) | 372 | if (d == NULL) |
350 | return 16; | 373 | return 16; |
351 | if (0 == port) | 374 | if (0 == port) |
375 | { | ||
376 | const union MHD_DaemonInfo *dinfo; | ||
377 | dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); | ||
378 | if ((NULL == dinfo) ||(0 == dinfo->port) ) | ||
352 | { | 379 | { |
353 | const union MHD_DaemonInfo *dinfo; | 380 | MHD_stop_daemon (d); return 32; |
354 | dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); | ||
355 | if (NULL == dinfo || 0 == dinfo->port) | ||
356 | { MHD_stop_daemon (d); return 32; } | ||
357 | port = (int)dinfo->port; | ||
358 | } | 381 | } |
382 | port = (int) dinfo->port; | ||
383 | } | ||
359 | start_timer (); | 384 | start_timer (); |
360 | ret_val = do_gets ((void*)(intptr_t)port); | 385 | ret_val = do_gets ((void*) (intptr_t) port); |
361 | if (!ret_val) | 386 | if (! ret_val) |
362 | stop (test_desc); | 387 | stop (test_desc); |
363 | MHD_stop_daemon (d); | 388 | MHD_stop_daemon (d); |
364 | if (ret_val) | 389 | if (ret_val) |
365 | { | 390 | { |
366 | fprintf (stderr, | 391 | fprintf (stderr, |
367 | "Error performing %s test: %s\n", test_desc, ret_val); | 392 | "Error performing %s test: %s\n", test_desc, ret_val); |
368 | return 4; | 393 | return 4; |
369 | } | 394 | } |
370 | return 0; | 395 | return 0; |
371 | } | 396 | } |
372 | 397 | ||
@@ -386,7 +411,7 @@ testExternalGet (int port) | |||
386 | char *ret_val; | 411 | char *ret_val; |
387 | int ret = 0; | 412 | int ret = 0; |
388 | 413 | ||
389 | if (MHD_NO != MHD_is_feature_supported(MHD_FEATURE_AUTODETECT_BIND_PORT)) | 414 | if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) |
390 | port = 0; | 415 | port = 0; |
391 | 416 | ||
392 | signal_done = 0; | 417 | signal_done = 0; |
@@ -395,66 +420,71 @@ testExternalGet (int port) | |||
395 | if (d == NULL) | 420 | if (d == NULL) |
396 | return 256; | 421 | return 256; |
397 | if (0 == port) | 422 | if (0 == port) |
423 | { | ||
424 | const union MHD_DaemonInfo *dinfo; | ||
425 | dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); | ||
426 | if ((NULL == dinfo) ||(0 == dinfo->port) ) | ||
398 | { | 427 | { |
399 | const union MHD_DaemonInfo *dinfo; | 428 | MHD_stop_daemon (d); return 32; |
400 | dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); | ||
401 | if (NULL == dinfo || 0 == dinfo->port) | ||
402 | { MHD_stop_daemon (d); return 32; } | ||
403 | port = (int)dinfo->port; | ||
404 | } | 429 | } |
430 | port = (int) dinfo->port; | ||
431 | } | ||
405 | if (0 != pthread_create (&pid, NULL, | 432 | if (0 != pthread_create (&pid, NULL, |
406 | &do_gets, (void*)(intptr_t)port)) | 433 | &do_gets, (void*) (intptr_t) port)) |
407 | { | 434 | { |
408 | MHD_stop_daemon(d); | 435 | MHD_stop_daemon (d); |
409 | return 512; | 436 | return 512; |
410 | } | 437 | } |
411 | start_timer (); | 438 | start_timer (); |
412 | 439 | ||
413 | while (0 == signal_done) | 440 | while (0 == signal_done) |
441 | { | ||
442 | max = 0; | ||
443 | FD_ZERO (&rs); | ||
444 | FD_ZERO (&ws); | ||
445 | FD_ZERO (&es); | ||
446 | if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &max)) | ||
447 | { | ||
448 | MHD_stop_daemon (d); | ||
449 | return 4096; | ||
450 | } | ||
451 | tret = MHD_get_timeout (d, &tt); | ||
452 | if (MHD_YES != tret) | ||
453 | tt = 1; | ||
454 | tv.tv_sec = tt / 1000; | ||
455 | tv.tv_usec = 1000 * (tt % 1000); | ||
456 | if (-1 == select (max + 1, &rs, &ws, &es, &tv)) | ||
414 | { | 457 | { |
415 | max = 0; | ||
416 | FD_ZERO (&rs); | ||
417 | FD_ZERO (&ws); | ||
418 | FD_ZERO (&es); | ||
419 | if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &max)) | ||
420 | { | ||
421 | MHD_stop_daemon (d); | ||
422 | return 4096; | ||
423 | } | ||
424 | tret = MHD_get_timeout (d, &tt); | ||
425 | if (MHD_YES != tret) tt = 1; | ||
426 | tv.tv_sec = tt / 1000; | ||
427 | tv.tv_usec = 1000 * (tt % 1000); | ||
428 | if (-1 == select (max + 1, &rs, &ws, &es, &tv)) | ||
429 | { | ||
430 | #ifdef MHD_POSIX_SOCKETS | 458 | #ifdef MHD_POSIX_SOCKETS |
431 | if (EINTR == errno) | 459 | if (EINTR == errno) |
432 | continue; | 460 | continue; |
433 | fprintf (stderr, | 461 | fprintf (stderr, |
434 | "select failed: %s\n", | 462 | "select failed: %s\n", |
435 | strerror (errno)); | 463 | strerror (errno)); |
436 | #else | 464 | #else |
437 | if (WSAEINVAL == WSAGetLastError() && 0 == rs.fd_count && 0 == ws.fd_count && 0 == es.fd_count) | 465 | if ((WSAEINVAL == WSAGetLastError ()) &&(0 == rs.fd_count) &&(0 == |
438 | { | 466 | ws.fd_count) |
439 | Sleep (1000); | 467 | &&(0 == es.fd_count) ) |
440 | continue; | 468 | { |
441 | } | 469 | Sleep (1000); |
470 | continue; | ||
471 | } | ||
442 | #endif | 472 | #endif |
443 | ret |= 1024; | 473 | ret |= 1024; |
444 | break; | 474 | break; |
445 | } | ||
446 | MHD_run_from_select(d, &rs, &ws, &es); | ||
447 | } | 475 | } |
476 | MHD_run_from_select (d, &rs, &ws, &es); | ||
477 | } | ||
448 | 478 | ||
449 | stop ("external select"); | 479 | stop ("external select"); |
450 | MHD_stop_daemon (d); | 480 | MHD_stop_daemon (d); |
451 | if (0 != pthread_join(pid, (void**)&ret_val) || | 481 | if ((0 != pthread_join (pid, (void**) &ret_val))|| |
452 | NULL != ret_val) | 482 | (NULL != ret_val) ) |
453 | { | 483 | { |
454 | fprintf (stderr, | 484 | fprintf (stderr, |
455 | "%s\n", ret_val); | 485 | "%s\n", ret_val); |
456 | ret |= 8; | 486 | ret |= 8; |
457 | } | 487 | } |
458 | if (ret) | 488 | if (ret) |
459 | fprintf (stderr, "Error performing test.\n"); | 489 | fprintf (stderr, "Error performing test.\n"); |
460 | return 0; | 490 | return 0; |
@@ -466,9 +496,9 @@ main (int argc, char *const *argv) | |||
466 | { | 496 | { |
467 | unsigned int errorCount = 0; | 497 | unsigned int errorCount = 0; |
468 | int port = 1100; | 498 | int port = 1100; |
469 | (void)argc; /* Unused. Silent compiler warning. */ | 499 | (void) argc; /* Unused. Silent compiler warning. */ |
470 | 500 | ||
471 | if (NULL == argv || 0 == argv[0]) | 501 | if ((NULL == argv)||(0 == argv[0])) |
472 | return 99; | 502 | return 99; |
473 | oneone = has_in_name (argv[0], "11"); | 503 | oneone = has_in_name (argv[0], "11"); |
474 | if (oneone) | 504 | if (oneone) |
@@ -476,8 +506,8 @@ main (int argc, char *const *argv) | |||
476 | if (0 != curl_global_init (CURL_GLOBAL_WIN32)) | 506 | if (0 != curl_global_init (CURL_GLOBAL_WIN32)) |
477 | return 2; | 507 | return 2; |
478 | response = MHD_create_response_from_buffer (strlen ("/hello_world"), | 508 | response = MHD_create_response_from_buffer (strlen ("/hello_world"), |
479 | "/hello_world", | 509 | "/hello_world", |
480 | MHD_RESPMEM_MUST_COPY); | 510 | MHD_RESPMEM_MUST_COPY); |
481 | errorCount += testInternalGet (port++, 0); | 511 | errorCount += testInternalGet (port++, 0); |
482 | errorCount += testMultithreadedGet (port++, 0); | 512 | errorCount += testMultithreadedGet (port++, 0); |
483 | errorCount += testMultithreadedPoolGet (port++, 0); | 513 | errorCount += testMultithreadedPoolGet (port++, 0); |
@@ -485,17 +515,17 @@ main (int argc, char *const *argv) | |||
485 | errorCount += testInternalGet (port++, MHD_USE_AUTO); | 515 | errorCount += testInternalGet (port++, MHD_USE_AUTO); |
486 | errorCount += testMultithreadedGet (port++, MHD_USE_AUTO); | 516 | errorCount += testMultithreadedGet (port++, MHD_USE_AUTO); |
487 | errorCount += testMultithreadedPoolGet (port++, MHD_USE_AUTO); | 517 | errorCount += testMultithreadedPoolGet (port++, MHD_USE_AUTO); |
488 | if (MHD_YES == MHD_is_feature_supported(MHD_FEATURE_POLL)) | 518 | if (MHD_YES == MHD_is_feature_supported (MHD_FEATURE_POLL)) |
489 | { | 519 | { |
490 | errorCount += testInternalGet (port++, MHD_USE_POLL); | 520 | errorCount += testInternalGet (port++, MHD_USE_POLL); |
491 | errorCount += testMultithreadedGet (port++, MHD_USE_POLL); | 521 | errorCount += testMultithreadedGet (port++, MHD_USE_POLL); |
492 | errorCount += testMultithreadedPoolGet (port++, MHD_USE_POLL); | 522 | errorCount += testMultithreadedPoolGet (port++, MHD_USE_POLL); |
493 | } | 523 | } |
494 | if (MHD_YES == MHD_is_feature_supported(MHD_FEATURE_EPOLL)) | 524 | if (MHD_YES == MHD_is_feature_supported (MHD_FEATURE_EPOLL)) |
495 | { | 525 | { |
496 | errorCount += testInternalGet (port++, MHD_USE_EPOLL); | 526 | errorCount += testInternalGet (port++, MHD_USE_EPOLL); |
497 | errorCount += testMultithreadedPoolGet (port++, MHD_USE_EPOLL); | 527 | errorCount += testMultithreadedPoolGet (port++, MHD_USE_EPOLL); |
498 | } | 528 | } |
499 | MHD_destroy_response (response); | 529 | MHD_destroy_response (response); |
500 | if (errorCount != 0) | 530 | if (errorCount != 0) |
501 | fprintf (stderr, "Error (code: %u)\n", errorCount); | 531 | fprintf (stderr, "Error (code: %u)\n", errorCount); |