diff options
author | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2014-03-06 13:22:35 +0000 |
---|---|---|
committer | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2014-03-06 13:22:35 +0000 |
commit | 20699d328b1327233cb9787ac4f92be09d244f4f (patch) | |
tree | 08215e32431c838bc0e1ab24400a9cf28d193c23 | |
parent | a9e36d372055530d4e949e5dd5369be87033a090 (diff) | |
download | libmicrohttpd-20699d328b1327233cb9787ac4f92be09d244f4f.tar.gz libmicrohttpd-20699d328b1327233cb9787ac4f92be09d244f4f.zip |
Use number of CPUs in tests and examples
25 files changed, 188 insertions, 24 deletions
diff --git a/configure.ac b/configure.ac index f461f57e..49091701 100644 --- a/configure.ac +++ b/configure.ac | |||
@@ -645,6 +645,8 @@ AC_ARG_ENABLE([coverage], | |||
645 | AC_MSG_RESULT($use_gcov) | 645 | AC_MSG_RESULT($use_gcov) |
646 | AM_CONDITIONAL([USE_COVERAGE], [test "x$use_gcov" = "xyes"]) | 646 | AM_CONDITIONAL([USE_COVERAGE], [test "x$use_gcov" = "xyes"]) |
647 | 647 | ||
648 | AX_COUNT_CPUS | ||
649 | AC_SUBST([CPU_COUNT]) | ||
648 | 650 | ||
649 | AC_SUBST(MHD_LIB_CPPFLAGS) | 651 | AC_SUBST(MHD_LIB_CPPFLAGS) |
650 | AC_SUBST(MHD_LIB_CFLAGS) | 652 | AC_SUBST(MHD_LIB_CFLAGS) |
diff --git a/src/examples/Makefile.am b/src/examples/Makefile.am index 540dd26d..fbd1920d 100644 --- a/src/examples/Makefile.am +++ b/src/examples/Makefile.am | |||
@@ -6,6 +6,8 @@ AM_CPPFLAGS = \ | |||
6 | 6 | ||
7 | AM_CFLAGS = @LIBGCRYPT_CFLAGS@ | 7 | AM_CFLAGS = @LIBGCRYPT_CFLAGS@ |
8 | 8 | ||
9 | CPU_COUNT_DEF = -DCPU_COUNT=$(CPU_COUNT) | ||
10 | |||
9 | if USE_COVERAGE | 11 | if USE_COVERAGE |
10 | AM_CFLAGS += --coverage | 12 | AM_CFLAGS += --coverage |
11 | endif | 13 | endif |
@@ -72,6 +74,8 @@ demo_SOURCES = \ | |||
72 | demo.c | 74 | demo.c |
73 | demo_CFLAGS = \ | 75 | demo_CFLAGS = \ |
74 | $(PTHREAD_CFLAGS) $(AM_CFLAGS) | 76 | $(PTHREAD_CFLAGS) $(AM_CFLAGS) |
77 | demo_CPPFLAGS = \ | ||
78 | $(AM_CPPFLAGS) $(CPU_COUNT_DEF) | ||
75 | demo_LDADD = \ | 79 | demo_LDADD = \ |
76 | $(top_builddir)/src/microhttpd/libmicrohttpd.la \ | 80 | $(top_builddir)/src/microhttpd/libmicrohttpd.la \ |
77 | $(PTHREAD_LIBS) -lmagic | 81 | $(PTHREAD_LIBS) -lmagic |
@@ -87,11 +91,15 @@ mhd2spdy_LDADD = \ | |||
87 | 91 | ||
88 | benchmark_SOURCES = \ | 92 | benchmark_SOURCES = \ |
89 | benchmark.c | 93 | benchmark.c |
94 | benchmark_CPPFLAGS = \ | ||
95 | $(AM_CPPFLAGS) $(CPU_COUNT_DEF) | ||
90 | benchmark_LDADD = \ | 96 | benchmark_LDADD = \ |
91 | $(top_builddir)/src/microhttpd/libmicrohttpd.la | 97 | $(top_builddir)/src/microhttpd/libmicrohttpd.la |
92 | 98 | ||
93 | benchmark_https_SOURCES = \ | 99 | benchmark_https_SOURCES = \ |
94 | benchmark_https.c | 100 | benchmark_https.c |
101 | benchmark_https_CPPFLAGS = \ | ||
102 | $(AM_CPPFLAGS) $(CPU_COUNT_DEF) | ||
95 | benchmark_https_LDADD = \ | 103 | benchmark_https_LDADD = \ |
96 | $(top_builddir)/src/microhttpd/libmicrohttpd.la | 104 | $(top_builddir)/src/microhttpd/libmicrohttpd.la |
97 | 105 | ||
diff --git a/src/examples/benchmark.c b/src/examples/benchmark.c index 97fa2c70..4cea24fa 100644 --- a/src/examples/benchmark.c +++ b/src/examples/benchmark.c | |||
@@ -25,6 +25,13 @@ | |||
25 | #include "platform.h" | 25 | #include "platform.h" |
26 | #include <microhttpd.h> | 26 | #include <microhttpd.h> |
27 | 27 | ||
28 | #if defined(CPU_COUNT) && (CPU_COUNT+0) < 2 | ||
29 | #undef CPU_COUNT | ||
30 | #endif | ||
31 | #if !defined(CPU_COUNT) | ||
32 | #define CPU_COUNT 2 | ||
33 | #endif | ||
34 | |||
28 | #define PAGE "<html><head><title>libmicrohttpd demo</title></head><body>libmicrohttpd demo</body></html>" | 35 | #define PAGE "<html><head><title>libmicrohttpd demo</title></head><body>libmicrohttpd demo</body></html>" |
29 | 36 | ||
30 | 37 | ||
@@ -34,7 +41,7 @@ | |||
34 | * Number of threads to run in the thread pool. Should (roughly) match | 41 | * Number of threads to run in the thread pool. Should (roughly) match |
35 | * the number of cores on your system. | 42 | * the number of cores on your system. |
36 | */ | 43 | */ |
37 | #define NUMBER_OF_THREADS 4 | 44 | #define NUMBER_OF_THREADS CPU_COUNT |
38 | 45 | ||
39 | static unsigned int small_deltas[SMALL]; | 46 | static unsigned int small_deltas[SMALL]; |
40 | 47 | ||
diff --git a/src/examples/benchmark_https.c b/src/examples/benchmark_https.c index d3f89eac..f4b5a33a 100644 --- a/src/examples/benchmark_https.c +++ b/src/examples/benchmark_https.c | |||
@@ -25,6 +25,13 @@ | |||
25 | #include "platform.h" | 25 | #include "platform.h" |
26 | #include <microhttpd.h> | 26 | #include <microhttpd.h> |
27 | 27 | ||
28 | #if defined(CPU_COUNT) && (CPU_COUNT+0) < 2 | ||
29 | #undef CPU_COUNT | ||
30 | #endif | ||
31 | #if !defined(CPU_COUNT) | ||
32 | #define CPU_COUNT 2 | ||
33 | #endif | ||
34 | |||
28 | #define PAGE "<html><head><title>libmicrohttpd demo</title></head><body>libmicrohttpd demo</body></html>" | 35 | #define PAGE "<html><head><title>libmicrohttpd demo</title></head><body>libmicrohttpd demo</body></html>" |
29 | 36 | ||
30 | 37 | ||
@@ -34,7 +41,7 @@ | |||
34 | * Number of threads to run in the thread pool. Should (roughly) match | 41 | * Number of threads to run in the thread pool. Should (roughly) match |
35 | * the number of cores on your system. | 42 | * the number of cores on your system. |
36 | */ | 43 | */ |
37 | #define NUMBER_OF_THREADS 4 | 44 | #define NUMBER_OF_THREADS CPU_COUNT |
38 | 45 | ||
39 | static unsigned int small_deltas[SMALL]; | 46 | static unsigned int small_deltas[SMALL]; |
40 | 47 | ||
diff --git a/src/examples/demo.c b/src/examples/demo.c index 4a16b656..10890ebe 100644 --- a/src/examples/demo.c +++ b/src/examples/demo.c | |||
@@ -39,11 +39,18 @@ | |||
39 | #include <limits.h> | 39 | #include <limits.h> |
40 | #include <ctype.h> | 40 | #include <ctype.h> |
41 | 41 | ||
42 | #if defined(CPU_COUNT) && (CPU_COUNT+0) < 2 | ||
43 | #undef CPU_COUNT | ||
44 | #endif | ||
45 | #if !defined(CPU_COUNT) | ||
46 | #define CPU_COUNT 2 | ||
47 | #endif | ||
48 | |||
42 | /** | 49 | /** |
43 | * Number of threads to run in the thread pool. Should (roughly) match | 50 | * Number of threads to run in the thread pool. Should (roughly) match |
44 | * the number of cores on your system. | 51 | * the number of cores on your system. |
45 | */ | 52 | */ |
46 | #define NUMBER_OF_THREADS 8 | 53 | #define NUMBER_OF_THREADS CPU_COUNT |
47 | 54 | ||
48 | /** | 55 | /** |
49 | * How many bytes of a file do we give to libmagic to determine the mime type? | 56 | * How many bytes of a file do we give to libmagic to determine the mime type? |
diff --git a/src/testcurl/Makefile.am b/src/testcurl/Makefile.am index fe17c75e..bf3937a0 100644 --- a/src/testcurl/Makefile.am +++ b/src/testcurl/Makefile.am | |||
@@ -9,6 +9,7 @@ if ENABLE_HTTPS | |||
9 | endif | 9 | endif |
10 | 10 | ||
11 | AM_CPPFLAGS = \ | 11 | AM_CPPFLAGS = \ |
12 | -DCPU_COUNT=$(CPU_COUNT) \ | ||
12 | -I$(top_srcdir) \ | 13 | -I$(top_srcdir) \ |
13 | -I$(top_srcdir)/src/microhttpd \ | 14 | -I$(top_srcdir)/src/microhttpd \ |
14 | -I$(top_srcdir)/src/include \ | 15 | -I$(top_srcdir)/src/include \ |
diff --git a/src/testcurl/https/Makefile.am b/src/testcurl/https/Makefile.am index e1a5f402..4053e536 100644 --- a/src/testcurl/https/Makefile.am +++ b/src/testcurl/https/Makefile.am | |||
@@ -4,6 +4,8 @@ if USE_COVERAGE | |||
4 | AM_CFLAGS = --coverage | 4 | AM_CFLAGS = --coverage |
5 | endif | 5 | endif |
6 | 6 | ||
7 | CPU_COUNT_DEF = -DCPU_COUNT=$(CPU_COUNT) | ||
8 | |||
7 | AM_CPPFLAGS = \ | 9 | AM_CPPFLAGS = \ |
8 | -I$(top_srcdir)/src/include \ | 10 | -I$(top_srcdir)/src/include \ |
9 | -I$(top_srcdir)/src/microhttpd \ | 11 | -I$(top_srcdir)/src/microhttpd \ |
@@ -59,6 +61,8 @@ test_tls_options_LDADD = \ | |||
59 | test_https_get_parallel_SOURCES = \ | 61 | test_https_get_parallel_SOURCES = \ |
60 | test_https_get_parallel.c \ | 62 | test_https_get_parallel.c \ |
61 | tls_test_common.c | 63 | tls_test_common.c |
64 | test_https_get_parallel_CPPFLAGS = \ | ||
65 | $(AM_CPPFLAGS) $(CPU_COUNT_DEF) | ||
62 | test_https_get_parallel_CFLAGS = \ | 66 | test_https_get_parallel_CFLAGS = \ |
63 | $(PTHREAD_CFLAGS) $(AM_CFLAGS) | 67 | $(PTHREAD_CFLAGS) $(AM_CFLAGS) |
64 | test_https_get_parallel_LDADD = \ | 68 | test_https_get_parallel_LDADD = \ |
@@ -77,6 +81,8 @@ test_empty_response_LDADD = \ | |||
77 | test_https_get_parallel_threads_SOURCES = \ | 81 | test_https_get_parallel_threads_SOURCES = \ |
78 | test_https_get_parallel_threads.c \ | 82 | test_https_get_parallel_threads.c \ |
79 | tls_test_common.c | 83 | tls_test_common.c |
84 | test_https_get_parallel_threads_CPPFLAGS = \ | ||
85 | $(AM_CPPFLAGS) $(CPU_COUNT_DEF) | ||
80 | test_https_get_parallel_threads_CFLAGS = \ | 86 | test_https_get_parallel_threads_CFLAGS = \ |
81 | $(PTHREAD_CFLAGS) $(AM_CFLAGS) | 87 | $(PTHREAD_CFLAGS) $(AM_CFLAGS) |
82 | test_https_get_parallel_threads_LDADD = \ | 88 | test_https_get_parallel_threads_LDADD = \ |
diff --git a/src/testcurl/https/test_https_get_parallel.c b/src/testcurl/https/test_https_get_parallel.c index 9ac330f0..eafc3d26 100644 --- a/src/testcurl/https/test_https_get_parallel.c +++ b/src/testcurl/https/test_https_get_parallel.c | |||
@@ -33,6 +33,13 @@ | |||
33 | #include <gcrypt.h> | 33 | #include <gcrypt.h> |
34 | #include "tls_test_common.h" | 34 | #include "tls_test_common.h" |
35 | 35 | ||
36 | #if defined(CPU_COUNT) && (CPU_COUNT+0) < 4 | ||
37 | #undef CPU_COUNT | ||
38 | #endif | ||
39 | #if !defined(CPU_COUNT) | ||
40 | #define CPU_COUNT 4 | ||
41 | #endif | ||
42 | |||
36 | extern const char srv_key_pem[]; | 43 | extern const char srv_key_pem[]; |
37 | extern const char srv_self_signed_cert_pem[]; | 44 | extern const char srv_self_signed_cert_pem[]; |
38 | 45 | ||
@@ -94,7 +101,7 @@ test_parallel_clients (void * cls, const char *cipher_suite, | |||
94 | int curl_proto_version) | 101 | int curl_proto_version) |
95 | { | 102 | { |
96 | int i; | 103 | int i; |
97 | int client_count = 3; | 104 | int client_count = (CPU_COUNT - 1); |
98 | void *client_thread_ret; | 105 | void *client_thread_ret; |
99 | pthread_t client_arr[client_count]; | 106 | pthread_t client_arr[client_count]; |
100 | struct https_test_data client_args = | 107 | struct https_test_data client_args = |
diff --git a/src/testcurl/https/test_https_get_parallel_threads.c b/src/testcurl/https/test_https_get_parallel_threads.c index 4e27370b..334276a3 100644 --- a/src/testcurl/https/test_https_get_parallel_threads.c +++ b/src/testcurl/https/test_https_get_parallel_threads.c | |||
@@ -35,6 +35,13 @@ | |||
35 | #include <gcrypt.h> | 35 | #include <gcrypt.h> |
36 | #include "tls_test_common.h" | 36 | #include "tls_test_common.h" |
37 | 37 | ||
38 | #if defined(CPU_COUNT) && (CPU_COUNT+0) < 4 | ||
39 | #undef CPU_COUNT | ||
40 | #endif | ||
41 | #if !defined(CPU_COUNT) | ||
42 | #define CPU_COUNT 4 | ||
43 | #endif | ||
44 | |||
38 | extern const char srv_key_pem[]; | 45 | extern const char srv_key_pem[]; |
39 | extern const char srv_self_signed_cert_pem[]; | 46 | extern const char srv_self_signed_cert_pem[]; |
40 | 47 | ||
@@ -94,7 +101,7 @@ test_parallel_clients (void *cls, const char *cipher_suite, | |||
94 | int curl_proto_version) | 101 | int curl_proto_version) |
95 | { | 102 | { |
96 | int i; | 103 | int i; |
97 | int client_count = 3; | 104 | int client_count = (CPU_COUNT - 1); |
98 | void *client_thread_ret; | 105 | void *client_thread_ret; |
99 | pthread_t client_arr[client_count]; | 106 | pthread_t client_arr[client_count]; |
100 | struct https_test_data client_args = | 107 | struct https_test_data client_args = |
diff --git a/src/testcurl/perf_get.c b/src/testcurl/perf_get.c index 835db66e..5554000a 100644 --- a/src/testcurl/perf_get.c +++ b/src/testcurl/perf_get.c | |||
@@ -50,6 +50,13 @@ | |||
50 | #include <sys/socket.h> | 50 | #include <sys/socket.h> |
51 | #endif | 51 | #endif |
52 | 52 | ||
53 | #if defined(CPU_COUNT) && (CPU_COUNT+0) < 2 | ||
54 | #undef CPU_COUNT | ||
55 | #endif | ||
56 | #if !defined(CPU_COUNT) | ||
57 | #define CPU_COUNT 2 | ||
58 | #endif | ||
59 | |||
53 | /** | 60 | /** |
54 | * How many rounds of operations do we do for each | 61 | * How many rounds of operations do we do for each |
55 | * test? | 62 | * test? |
@@ -306,7 +313,7 @@ testMultithreadedPoolGet (int port, int poll_flag) | |||
306 | cbc.size = 2048; | 313 | cbc.size = 2048; |
307 | d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG | poll_flag, | 314 | d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG | poll_flag, |
308 | port, NULL, NULL, &ahc_echo, "GET", | 315 | port, NULL, NULL, &ahc_echo, "GET", |
309 | MHD_OPTION_THREAD_POOL_SIZE, 4, MHD_OPTION_END); | 316 | MHD_OPTION_THREAD_POOL_SIZE, CPU_COUNT, MHD_OPTION_END); |
310 | if (d == NULL) | 317 | if (d == NULL) |
311 | return 16; | 318 | return 16; |
312 | start_timer (); | 319 | start_timer (); |
diff --git a/src/testcurl/perf_get_concurrent.c b/src/testcurl/perf_get_concurrent.c index cec87a99..82f240d7 100644 --- a/src/testcurl/perf_get_concurrent.c +++ b/src/testcurl/perf_get_concurrent.c | |||
@@ -41,6 +41,13 @@ | |||
41 | #include <time.h> | 41 | #include <time.h> |
42 | #include "gauger.h" | 42 | #include "gauger.h" |
43 | 43 | ||
44 | #if defined(CPU_COUNT) && (CPU_COUNT+0) < 2 | ||
45 | #undef CPU_COUNT | ||
46 | #endif | ||
47 | #if !defined(CPU_COUNT) | ||
48 | #define CPU_COUNT 2 | ||
49 | #endif | ||
50 | |||
44 | /** | 51 | /** |
45 | * How many rounds of operations do we do for each | 52 | * How many rounds of operations do we do for each |
46 | * test (total number of requests will be ROUNDS * PAR). | 53 | * test (total number of requests will be ROUNDS * PAR). |
@@ -50,7 +57,7 @@ | |||
50 | /** | 57 | /** |
51 | * How many requests do we do in parallel? | 58 | * How many requests do we do in parallel? |
52 | */ | 59 | */ |
53 | #define PAR 4 | 60 | #define PAR CPU_COUNT |
54 | 61 | ||
55 | /** | 62 | /** |
56 | * Do we use HTTP 1.1? | 63 | * Do we use HTTP 1.1? |
@@ -262,7 +269,7 @@ testMultithreadedPoolGet (int port, int poll_flag) | |||
262 | 269 | ||
263 | d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG | poll_flag, | 270 | d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG | poll_flag, |
264 | port, NULL, NULL, &ahc_echo, "GET", | 271 | port, NULL, NULL, &ahc_echo, "GET", |
265 | MHD_OPTION_THREAD_POOL_SIZE, 4, MHD_OPTION_END); | 272 | MHD_OPTION_THREAD_POOL_SIZE, CPU_COUNT, MHD_OPTION_END); |
266 | if (d == NULL) | 273 | if (d == NULL) |
267 | return 16; | 274 | return 16; |
268 | start_timer (); | 275 | start_timer (); |
diff --git a/src/testcurl/test_get.c b/src/testcurl/test_get.c index 95050855..142b41f4 100644 --- a/src/testcurl/test_get.c +++ b/src/testcurl/test_get.c | |||
@@ -46,6 +46,13 @@ | |||
46 | #include <sys/socket.h> | 46 | #include <sys/socket.h> |
47 | #endif | 47 | #endif |
48 | 48 | ||
49 | #if defined(CPU_COUNT) && (CPU_COUNT+0) < 2 | ||
50 | #undef CPU_COUNT | ||
51 | #endif | ||
52 | #if !defined(CPU_COUNT) | ||
53 | #define CPU_COUNT 2 | ||
54 | #endif | ||
55 | |||
49 | static int oneone; | 56 | static int oneone; |
50 | 57 | ||
51 | struct CBC | 58 | struct CBC |
@@ -214,7 +221,7 @@ testMultithreadedPoolGet (int poll_flag) | |||
214 | cbc.pos = 0; | 221 | cbc.pos = 0; |
215 | d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG | poll_flag, | 222 | d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG | poll_flag, |
216 | 1081, NULL, NULL, &ahc_echo, "GET", | 223 | 1081, NULL, NULL, &ahc_echo, "GET", |
217 | MHD_OPTION_THREAD_POOL_SIZE, 4, MHD_OPTION_END); | 224 | MHD_OPTION_THREAD_POOL_SIZE, CPU_COUNT, MHD_OPTION_END); |
218 | if (d == NULL) | 225 | if (d == NULL) |
219 | return 16; | 226 | return 16; |
220 | c = curl_easy_init (); | 227 | c = curl_easy_init (); |
diff --git a/src/testcurl/test_get_chunked.c b/src/testcurl/test_get_chunked.c index c9528d37..a720ace7 100644 --- a/src/testcurl/test_get_chunked.c +++ b/src/testcurl/test_get_chunked.c | |||
@@ -40,6 +40,13 @@ | |||
40 | #include <unistd.h> | 40 | #include <unistd.h> |
41 | #endif | 41 | #endif |
42 | 42 | ||
43 | #if defined(CPU_COUNT) && (CPU_COUNT+0) < 2 | ||
44 | #undef CPU_COUNT | ||
45 | #endif | ||
46 | #if !defined(CPU_COUNT) | ||
47 | #define CPU_COUNT 2 | ||
48 | #endif | ||
49 | |||
43 | struct CBC | 50 | struct CBC |
44 | { | 51 | { |
45 | char *buf; | 52 | char *buf; |
@@ -243,7 +250,7 @@ testMultithreadedPoolGet () | |||
243 | cbc.pos = 0; | 250 | cbc.pos = 0; |
244 | d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG, | 251 | d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG, |
245 | 1081, NULL, NULL, &ahc_echo, "GET", | 252 | 1081, NULL, NULL, &ahc_echo, "GET", |
246 | MHD_OPTION_THREAD_POOL_SIZE, 4, MHD_OPTION_END); | 253 | MHD_OPTION_THREAD_POOL_SIZE, CPU_COUNT, MHD_OPTION_END); |
247 | if (d == NULL) | 254 | if (d == NULL) |
248 | return 16; | 255 | return 16; |
249 | c = curl_easy_init (); | 256 | c = curl_easy_init (); |
diff --git a/src/testcurl/test_get_response_cleanup.c b/src/testcurl/test_get_response_cleanup.c index 39d7ece6..32c24ae3 100644 --- a/src/testcurl/test_get_response_cleanup.c +++ b/src/testcurl/test_get_response_cleanup.c | |||
@@ -48,6 +48,13 @@ | |||
48 | #include <windows.h> | 48 | #include <windows.h> |
49 | #endif | 49 | #endif |
50 | 50 | ||
51 | #if defined(CPU_COUNT) && (CPU_COUNT+0) < 2 | ||
52 | #undef CPU_COUNT | ||
53 | #endif | ||
54 | #if !defined(CPU_COUNT) | ||
55 | #define CPU_COUNT 2 | ||
56 | #endif | ||
57 | |||
51 | #define TESTSTR "/* DO NOT CHANGE THIS LINE */" | 58 | #define TESTSTR "/* DO NOT CHANGE THIS LINE */" |
52 | 59 | ||
53 | static int oneone; | 60 | static int oneone; |
@@ -202,7 +209,7 @@ testMultithreadedPoolGet () | |||
202 | 209 | ||
203 | d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG, | 210 | d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG, |
204 | 1081, NULL, NULL, &ahc_echo, "GET", | 211 | 1081, NULL, NULL, &ahc_echo, "GET", |
205 | MHD_OPTION_THREAD_POOL_SIZE, 4, MHD_OPTION_END); | 212 | MHD_OPTION_THREAD_POOL_SIZE, CPU_COUNT, MHD_OPTION_END); |
206 | if (d == NULL) | 213 | if (d == NULL) |
207 | return 64; | 214 | return 64; |
208 | ok = 1; | 215 | ok = 1; |
diff --git a/src/testcurl/test_get_sendfile.c b/src/testcurl/test_get_sendfile.c index 5fdc9b4c..ded4de60 100644 --- a/src/testcurl/test_get_sendfile.c +++ b/src/testcurl/test_get_sendfile.c | |||
@@ -40,6 +40,13 @@ | |||
40 | #include <unistd.h> | 40 | #include <unistd.h> |
41 | #endif | 41 | #endif |
42 | 42 | ||
43 | #if defined(CPU_COUNT) && (CPU_COUNT+0) < 2 | ||
44 | #undef CPU_COUNT | ||
45 | #endif | ||
46 | #if !defined(CPU_COUNT) | ||
47 | #define CPU_COUNT 2 | ||
48 | #endif | ||
49 | |||
43 | #define TESTSTR "This is the content of the test file we are sending using sendfile (if available)" | 50 | #define TESTSTR "This is the content of the test file we are sending using sendfile (if available)" |
44 | 51 | ||
45 | char *sourcefile; | 52 | char *sourcefile; |
@@ -218,7 +225,7 @@ testMultithreadedPoolGet () | |||
218 | cbc.pos = 0; | 225 | cbc.pos = 0; |
219 | d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG, | 226 | d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG, |
220 | 1081, NULL, NULL, &ahc_echo, "GET", | 227 | 1081, NULL, NULL, &ahc_echo, "GET", |
221 | MHD_OPTION_THREAD_POOL_SIZE, 4, MHD_OPTION_END); | 228 | MHD_OPTION_THREAD_POOL_SIZE, CPU_COUNT, MHD_OPTION_END); |
222 | if (d == NULL) | 229 | if (d == NULL) |
223 | return 16; | 230 | return 16; |
224 | c = curl_easy_init (); | 231 | c = curl_easy_init (); |
diff --git a/src/testcurl/test_iplimit.c b/src/testcurl/test_iplimit.c index cf06a972..0a96a3ba 100644 --- a/src/testcurl/test_iplimit.c +++ b/src/testcurl/test_iplimit.c | |||
@@ -44,6 +44,13 @@ | |||
44 | #include <windows.h> | 44 | #include <windows.h> |
45 | #endif | 45 | #endif |
46 | 46 | ||
47 | #if defined(CPU_COUNT) && (CPU_COUNT+0) < 2 | ||
48 | #undef CPU_COUNT | ||
49 | #endif | ||
50 | #if !defined(CPU_COUNT) | ||
51 | #define CPU_COUNT 2 | ||
52 | #endif | ||
53 | |||
47 | static int oneone; | 54 | static int oneone; |
48 | 55 | ||
49 | struct CBC | 56 | struct CBC |
@@ -208,7 +215,7 @@ testMultithreadedPoolGet () | |||
208 | d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG, | 215 | d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG, |
209 | 1081, NULL, NULL, &ahc_echo, "GET", | 216 | 1081, NULL, NULL, &ahc_echo, "GET", |
210 | MHD_OPTION_PER_IP_CONNECTION_LIMIT, 2, | 217 | MHD_OPTION_PER_IP_CONNECTION_LIMIT, 2, |
211 | MHD_OPTION_THREAD_POOL_SIZE, 4, | 218 | MHD_OPTION_THREAD_POOL_SIZE, CPU_COUNT, |
212 | MHD_OPTION_END); | 219 | MHD_OPTION_END); |
213 | if (d == NULL) | 220 | if (d == NULL) |
214 | return 16; | 221 | return 16; |
diff --git a/src/testcurl/test_large_put.c b/src/testcurl/test_large_put.c index 8b37fc30..0baa9087 100644 --- a/src/testcurl/test_large_put.c +++ b/src/testcurl/test_large_put.c | |||
@@ -36,6 +36,13 @@ | |||
36 | #include <unistd.h> | 36 | #include <unistd.h> |
37 | #endif | 37 | #endif |
38 | 38 | ||
39 | #if defined(CPU_COUNT) && (CPU_COUNT+0) < 2 | ||
40 | #undef CPU_COUNT | ||
41 | #endif | ||
42 | #if !defined(CPU_COUNT) | ||
43 | #define CPU_COUNT 2 | ||
44 | #endif | ||
45 | |||
39 | static int oneone; | 46 | static int oneone; |
40 | 47 | ||
41 | /** | 48 | /** |
@@ -267,7 +274,7 @@ testMultithreadedPoolPut () | |||
267 | d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG, | 274 | d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG, |
268 | 1081, | 275 | 1081, |
269 | NULL, NULL, &ahc_echo, &done_flag, | 276 | NULL, NULL, &ahc_echo, &done_flag, |
270 | MHD_OPTION_THREAD_POOL_SIZE, 4, | 277 | MHD_OPTION_THREAD_POOL_SIZE, CPU_COUNT, |
271 | MHD_OPTION_CONNECTION_MEMORY_LIMIT, (size_t) (1024*1024), | 278 | MHD_OPTION_CONNECTION_MEMORY_LIMIT, (size_t) (1024*1024), |
272 | MHD_OPTION_END); | 279 | MHD_OPTION_END); |
273 | if (d == NULL) | 280 | if (d == NULL) |
diff --git a/src/testcurl/test_post.c b/src/testcurl/test_post.c index a0be0f94..f6f79935 100644 --- a/src/testcurl/test_post.c +++ b/src/testcurl/test_post.c | |||
@@ -43,6 +43,13 @@ | |||
43 | #include <windows.h> | 43 | #include <windows.h> |
44 | #endif | 44 | #endif |
45 | 45 | ||
46 | #if defined(CPU_COUNT) && (CPU_COUNT+0) < 2 | ||
47 | #undef CPU_COUNT | ||
48 | #endif | ||
49 | #if !defined(CPU_COUNT) | ||
50 | #define CPU_COUNT 2 | ||
51 | #endif | ||
52 | |||
46 | #define POST_DATA "name=daniel&project=curl" | 53 | #define POST_DATA "name=daniel&project=curl" |
47 | 54 | ||
48 | static int oneone; | 55 | static int oneone; |
@@ -273,7 +280,7 @@ testMultithreadedPoolPost () | |||
273 | cbc.pos = 0; | 280 | cbc.pos = 0; |
274 | d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG, | 281 | d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG, |
275 | 1081, NULL, NULL, &ahc_echo, NULL, | 282 | 1081, NULL, NULL, &ahc_echo, NULL, |
276 | MHD_OPTION_THREAD_POOL_SIZE, 4, | 283 | MHD_OPTION_THREAD_POOL_SIZE, CPU_COUNT, |
277 | MHD_OPTION_NOTIFY_COMPLETED, &completed_cb, NULL, | 284 | MHD_OPTION_NOTIFY_COMPLETED, &completed_cb, NULL, |
278 | MHD_OPTION_END); | 285 | MHD_OPTION_END); |
279 | if (d == NULL) | 286 | if (d == NULL) |
diff --git a/src/testcurl/test_post_loop.c b/src/testcurl/test_post_loop.c index c9a1283e..c3b70687 100644 --- a/src/testcurl/test_post_loop.c +++ b/src/testcurl/test_post_loop.c | |||
@@ -37,6 +37,13 @@ | |||
37 | #include <unistd.h> | 37 | #include <unistd.h> |
38 | #endif | 38 | #endif |
39 | 39 | ||
40 | #if defined(CPU_COUNT) && (CPU_COUNT+0) < 2 | ||
41 | #undef CPU_COUNT | ||
42 | #endif | ||
43 | #if !defined(CPU_COUNT) | ||
44 | #define CPU_COUNT 2 | ||
45 | #endif | ||
46 | |||
40 | #define POST_DATA "<?xml version='1.0' ?>\n<xml>\n<data-id>1</data-id>\n</xml>\n" | 47 | #define POST_DATA "<?xml version='1.0' ?>\n<xml>\n<data-id>1</data-id>\n</xml>\n" |
41 | 48 | ||
42 | #define LOOPCOUNT 1000 | 49 | #define LOOPCOUNT 1000 |
@@ -242,7 +249,7 @@ testMultithreadedPoolPost () | |||
242 | cbc.size = 2048; | 249 | cbc.size = 2048; |
243 | d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG, | 250 | d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG, |
244 | 1081, NULL, NULL, &ahc_echo, NULL, | 251 | 1081, NULL, NULL, &ahc_echo, NULL, |
245 | MHD_OPTION_THREAD_POOL_SIZE, 4, MHD_OPTION_END); | 252 | MHD_OPTION_THREAD_POOL_SIZE, CPU_COUNT, MHD_OPTION_END); |
246 | if (d == NULL) | 253 | if (d == NULL) |
247 | return 16; | 254 | return 16; |
248 | for (i = 0; i < LOOPCOUNT; i++) | 255 | for (i = 0; i < LOOPCOUNT; i++) |
diff --git a/src/testcurl/test_postform.c b/src/testcurl/test_postform.c index 1af7af50..9efacb4d 100644 --- a/src/testcurl/test_postform.c +++ b/src/testcurl/test_postform.c | |||
@@ -39,6 +39,13 @@ | |||
39 | #include <unistd.h> | 39 | #include <unistd.h> |
40 | #endif | 40 | #endif |
41 | 41 | ||
42 | #if defined(CPU_COUNT) && (CPU_COUNT+0) < 2 | ||
43 | #undef CPU_COUNT | ||
44 | #endif | ||
45 | #if !defined(CPU_COUNT) | ||
46 | #define CPU_COUNT 2 | ||
47 | #endif | ||
48 | |||
42 | static int oneone; | 49 | static int oneone; |
43 | 50 | ||
44 | struct CBC | 51 | struct CBC |
@@ -290,7 +297,7 @@ testMultithreadedPoolPost () | |||
290 | cbc.pos = 0; | 297 | cbc.pos = 0; |
291 | d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG, | 298 | d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG, |
292 | 1081, NULL, NULL, &ahc_echo, NULL, | 299 | 1081, NULL, NULL, &ahc_echo, NULL, |
293 | MHD_OPTION_THREAD_POOL_SIZE, 4, | 300 | MHD_OPTION_THREAD_POOL_SIZE, CPU_COUNT, |
294 | MHD_OPTION_NOTIFY_COMPLETED, &completed_cb, NULL, | 301 | MHD_OPTION_NOTIFY_COMPLETED, &completed_cb, NULL, |
295 | MHD_OPTION_END); | 302 | MHD_OPTION_END); |
296 | if (d == NULL) | 303 | if (d == NULL) |
diff --git a/src/testcurl/test_process_headers.c b/src/testcurl/test_process_headers.c index 1962d7db..b838bc74 100644 --- a/src/testcurl/test_process_headers.c +++ b/src/testcurl/test_process_headers.c | |||
@@ -37,6 +37,13 @@ | |||
37 | #include <unistd.h> | 37 | #include <unistd.h> |
38 | #endif | 38 | #endif |
39 | 39 | ||
40 | #if defined(CPU_COUNT) && (CPU_COUNT+0) < 2 | ||
41 | #undef CPU_COUNT | ||
42 | #endif | ||
43 | #if !defined(CPU_COUNT) | ||
44 | #define CPU_COUNT 2 | ||
45 | #endif | ||
46 | |||
40 | static int oneone; | 47 | static int oneone; |
41 | 48 | ||
42 | struct CBC | 49 | struct CBC |
@@ -250,7 +257,7 @@ testMultithreadedPoolGet () | |||
250 | cbc.pos = 0; | 257 | cbc.pos = 0; |
251 | d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG, | 258 | d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG, |
252 | 21080, NULL, NULL, &ahc_echo, "GET", | 259 | 21080, NULL, NULL, &ahc_echo, "GET", |
253 | MHD_OPTION_THREAD_POOL_SIZE, 4, MHD_OPTION_END); | 260 | MHD_OPTION_THREAD_POOL_SIZE, CPU_COUNT, MHD_OPTION_END); |
254 | if (d == NULL) | 261 | if (d == NULL) |
255 | return 16; | 262 | return 16; |
256 | c = curl_easy_init (); | 263 | c = curl_easy_init (); |
diff --git a/src/testcurl/test_put.c b/src/testcurl/test_put.c index ce3d8de7..4f7e0f6b 100644 --- a/src/testcurl/test_put.c +++ b/src/testcurl/test_put.c | |||
@@ -36,6 +36,13 @@ | |||
36 | #include <unistd.h> | 36 | #include <unistd.h> |
37 | #endif | 37 | #endif |
38 | 38 | ||
39 | #if defined(CPU_COUNT) && (CPU_COUNT+0) < 2 | ||
40 | #undef CPU_COUNT | ||
41 | #endif | ||
42 | #if !defined(CPU_COUNT) | ||
43 | #define CPU_COUNT 2 | ||
44 | #endif | ||
45 | |||
39 | static int oneone; | 46 | static int oneone; |
40 | 47 | ||
41 | struct CBC | 48 | struct CBC |
@@ -240,7 +247,7 @@ testMultithreadedPoolPut () | |||
240 | d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG, | 247 | d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG, |
241 | 1081, | 248 | 1081, |
242 | NULL, NULL, &ahc_echo, &done_flag, | 249 | NULL, NULL, &ahc_echo, &done_flag, |
243 | MHD_OPTION_THREAD_POOL_SIZE, 4, MHD_OPTION_END); | 250 | MHD_OPTION_THREAD_POOL_SIZE, CPU_COUNT, MHD_OPTION_END); |
244 | if (d == NULL) | 251 | if (d == NULL) |
245 | return 16; | 252 | return 16; |
246 | c = curl_easy_init (); | 253 | c = curl_easy_init (); |
diff --git a/src/testcurl/test_put_chunked.c b/src/testcurl/test_put_chunked.c index decde05b..56af894a 100644 --- a/src/testcurl/test_put_chunked.c +++ b/src/testcurl/test_put_chunked.c | |||
@@ -37,6 +37,13 @@ | |||
37 | #include <unistd.h> | 37 | #include <unistd.h> |
38 | #endif | 38 | #endif |
39 | 39 | ||
40 | #if defined(CPU_COUNT) && (CPU_COUNT+0) < 2 | ||
41 | #undef CPU_COUNT | ||
42 | #endif | ||
43 | #if !defined(CPU_COUNT) | ||
44 | #define CPU_COUNT 2 | ||
45 | #endif | ||
46 | |||
40 | struct CBC | 47 | struct CBC |
41 | { | 48 | { |
42 | char *buf; | 49 | char *buf; |
@@ -250,7 +257,7 @@ testMultithreadedPoolPut () | |||
250 | d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG, | 257 | d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG, |
251 | 11081, | 258 | 11081, |
252 | NULL, NULL, &ahc_echo, &done_flag, | 259 | NULL, NULL, &ahc_echo, &done_flag, |
253 | MHD_OPTION_THREAD_POOL_SIZE, 4, MHD_OPTION_END); | 260 | MHD_OPTION_THREAD_POOL_SIZE, CPU_COUNT, MHD_OPTION_END); |
254 | if (d == NULL) | 261 | if (d == NULL) |
255 | return 16; | 262 | return 16; |
256 | c = curl_easy_init (); | 263 | c = curl_easy_init (); |
diff --git a/src/testcurl/test_quiesce.c b/src/testcurl/test_quiesce.c index d02dccc1..4e9012ff 100644 --- a/src/testcurl/test_quiesce.c +++ b/src/testcurl/test_quiesce.c | |||
@@ -39,6 +39,13 @@ | |||
39 | #include <sys/socket.h> | 39 | #include <sys/socket.h> |
40 | #endif | 40 | #endif |
41 | 41 | ||
42 | #if defined(CPU_COUNT) && (CPU_COUNT+0) < 2 | ||
43 | #undef CPU_COUNT | ||
44 | #endif | ||
45 | #if !defined(CPU_COUNT) | ||
46 | #define CPU_COUNT 2 | ||
47 | #endif | ||
48 | |||
42 | static int oneone; | 49 | static int oneone; |
43 | 50 | ||
44 | 51 | ||
@@ -436,16 +443,16 @@ main (int argc, char *const *argv) | |||
436 | return 2; | 443 | return 2; |
437 | errorCount += testGet (MHD_USE_SELECT_INTERNALLY, 0, 0); | 444 | errorCount += testGet (MHD_USE_SELECT_INTERNALLY, 0, 0); |
438 | errorCount += testGet (MHD_USE_THREAD_PER_CONNECTION, 0, 0); | 445 | errorCount += testGet (MHD_USE_THREAD_PER_CONNECTION, 0, 0); |
439 | errorCount += testGet (MHD_USE_SELECT_INTERNALLY, 4, 0); | 446 | errorCount += testGet (MHD_USE_SELECT_INTERNALLY, CPU_COUNT, 0); |
440 | errorCount += testExternalGet (); | 447 | errorCount += testExternalGet (); |
441 | #ifndef WINDOWS | 448 | #ifndef WINDOWS |
442 | errorCount += testGet (MHD_USE_SELECT_INTERNALLY, 0, MHD_USE_POLL); | 449 | errorCount += testGet (MHD_USE_SELECT_INTERNALLY, 0, MHD_USE_POLL); |
443 | errorCount += testGet (MHD_USE_THREAD_PER_CONNECTION, 0, MHD_USE_POLL); | 450 | errorCount += testGet (MHD_USE_THREAD_PER_CONNECTION, 0, MHD_USE_POLL); |
444 | errorCount += testGet (MHD_USE_SELECT_INTERNALLY, 4, MHD_USE_POLL); | 451 | errorCount += testGet (MHD_USE_SELECT_INTERNALLY, CPU_COUNT, MHD_USE_POLL); |
445 | #endif | 452 | #endif |
446 | #if EPOLL_SUPPORT | 453 | #if EPOLL_SUPPORT |
447 | errorCount += testGet (MHD_USE_SELECT_INTERNALLY, 0, MHD_USE_EPOLL_LINUX_ONLY); | 454 | errorCount += testGet (MHD_USE_SELECT_INTERNALLY, 0, MHD_USE_EPOLL_LINUX_ONLY); |
448 | errorCount += testGet (MHD_USE_SELECT_INTERNALLY, 4, MHD_USE_EPOLL_LINUX_ONLY); | 455 | errorCount += testGet (MHD_USE_SELECT_INTERNALLY, CPU_COUNT, MHD_USE_EPOLL_LINUX_ONLY); |
449 | #endif | 456 | #endif |
450 | if (errorCount != 0) | 457 | if (errorCount != 0) |
451 | fprintf (stderr, "Error (code: %u)\n", errorCount); | 458 | fprintf (stderr, "Error (code: %u)\n", errorCount); |
diff --git a/src/testcurl/test_start_stop.c b/src/testcurl/test_start_stop.c index b3be9937..9089f3a3 100644 --- a/src/testcurl/test_start_stop.c +++ b/src/testcurl/test_start_stop.c | |||
@@ -28,6 +28,13 @@ | |||
28 | #include <curl/curl.h> | 28 | #include <curl/curl.h> |
29 | #include <microhttpd.h> | 29 | #include <microhttpd.h> |
30 | 30 | ||
31 | #if defined(CPU_COUNT) && (CPU_COUNT+0) < 2 | ||
32 | #undef CPU_COUNT | ||
33 | #endif | ||
34 | #if !defined(CPU_COUNT) | ||
35 | #define CPU_COUNT 2 | ||
36 | #endif | ||
37 | |||
31 | 38 | ||
32 | static int | 39 | static int |
33 | ahc_echo (void *cls, | 40 | ahc_echo (void *cls, |
@@ -75,7 +82,7 @@ testMultithreadedPoolGet (int poll_flag) | |||
75 | 82 | ||
76 | d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG | poll_flag, | 83 | d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG | poll_flag, |
77 | 1081, NULL, NULL, &ahc_echo, "GET", | 84 | 1081, NULL, NULL, &ahc_echo, "GET", |
78 | MHD_OPTION_THREAD_POOL_SIZE, 4, MHD_OPTION_END); | 85 | MHD_OPTION_THREAD_POOL_SIZE, CPU_COUNT, MHD_OPTION_END); |
79 | if (d == NULL) | 86 | if (d == NULL) |
80 | return 4; | 87 | return 4; |
81 | MHD_stop_daemon (d); | 88 | MHD_stop_daemon (d); |