diff options
Diffstat (limited to 'src/testzzuf/daemontest_get.c')
-rw-r--r-- | src/testzzuf/daemontest_get.c | 253 |
1 files changed, 128 insertions, 125 deletions
diff --git a/src/testzzuf/daemontest_get.c b/src/testzzuf/daemontest_get.c index d7b11f3e..ac43f75e 100644 --- a/src/testzzuf/daemontest_get.c +++ b/src/testzzuf/daemontest_get.c | |||
@@ -112,33 +112,34 @@ testInternalGet () | |||
112 | cbc.buf = buf; | 112 | cbc.buf = buf; |
113 | cbc.size = 2048; | 113 | cbc.size = 2048; |
114 | cbc.pos = 0; | 114 | cbc.pos = 0; |
115 | d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY /* | MHD_USE_DEBUG */, | 115 | d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY /* | MHD_USE_DEBUG */ , |
116 | 11080, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); | 116 | 11080, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); |
117 | if (d == NULL) | 117 | if (d == NULL) |
118 | return 1; | 118 | return 1; |
119 | zzuf_socat_start(); | 119 | zzuf_socat_start (); |
120 | for (i=0;i<LOOP_COUNT;i++) { | 120 | for (i = 0; i < LOOP_COUNT; i++) |
121 | fprintf(stderr, "."); | 121 | { |
122 | c = curl_easy_init (); | 122 | fprintf (stderr, "."); |
123 | curl_easy_setopt (c, CURLOPT_URL, "http://localhost:11081/hello_world"); | 123 | c = curl_easy_init (); |
124 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); | 124 | curl_easy_setopt (c, CURLOPT_URL, "http://localhost:11081/hello_world"); |
125 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); | 125 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); |
126 | curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); | 126 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); |
127 | curl_easy_setopt (c, CURLOPT_TIMEOUT_MS, CURL_TIMEOUT); | 127 | curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); |
128 | curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT_MS, CURL_TIMEOUT); | 128 | curl_easy_setopt (c, CURLOPT_TIMEOUT_MS, CURL_TIMEOUT); |
129 | if (oneone) | 129 | curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT_MS, CURL_TIMEOUT); |
130 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); | 130 | if (oneone) |
131 | else | 131 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); |
132 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); | 132 | else |
133 | // NOTE: use of CONNECTTIMEOUT without also | 133 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); |
134 | // setting NOSIGNAL results in really weird | 134 | // NOTE: use of CONNECTTIMEOUT without also |
135 | // crashes on my system! | 135 | // setting NOSIGNAL results in really weird |
136 | curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1); | 136 | // crashes on my system! |
137 | curl_easy_perform (c); | 137 | curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1); |
138 | curl_easy_cleanup (c); | 138 | curl_easy_perform (c); |
139 | } | 139 | curl_easy_cleanup (c); |
140 | fprintf(stderr, "\n"); | 140 | } |
141 | zzuf_socat_stop(); | 141 | fprintf (stderr, "\n"); |
142 | zzuf_socat_stop (); | ||
142 | MHD_stop_daemon (d); | 143 | MHD_stop_daemon (d); |
143 | return 0; | 144 | return 0; |
144 | } | 145 | } |
@@ -155,33 +156,34 @@ testMultithreadedGet () | |||
155 | cbc.buf = buf; | 156 | cbc.buf = buf; |
156 | cbc.size = 2048; | 157 | cbc.size = 2048; |
157 | cbc.pos = 0; | 158 | cbc.pos = 0; |
158 | d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION /* | MHD_USE_DEBUG */, | 159 | d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION /* | MHD_USE_DEBUG */ , |
159 | 11080, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); | 160 | 11080, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); |
160 | if (d == NULL) | 161 | if (d == NULL) |
161 | return 16; | 162 | return 16; |
162 | zzuf_socat_start(); | 163 | zzuf_socat_start (); |
163 | for (i=0;i<LOOP_COUNT;i++) { | 164 | for (i = 0; i < LOOP_COUNT; i++) |
164 | fprintf(stderr, "."); | 165 | { |
165 | c = curl_easy_init (); | 166 | fprintf (stderr, "."); |
166 | curl_easy_setopt (c, CURLOPT_URL, "http://localhost:11081/hello_world"); | 167 | c = curl_easy_init (); |
167 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); | 168 | curl_easy_setopt (c, CURLOPT_URL, "http://localhost:11081/hello_world"); |
168 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); | 169 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); |
169 | curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); | 170 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); |
170 | curl_easy_setopt (c, CURLOPT_TIMEOUT_MS, CURL_TIMEOUT); | 171 | curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); |
171 | if (oneone) | 172 | curl_easy_setopt (c, CURLOPT_TIMEOUT_MS, CURL_TIMEOUT); |
172 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); | 173 | if (oneone) |
173 | else | 174 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); |
174 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); | 175 | else |
175 | curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT_MS, CURL_TIMEOUT); | 176 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); |
176 | // NOTE: use of CONNECTTIMEOUT without also | 177 | curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT_MS, CURL_TIMEOUT); |
177 | // setting NOSIGNAL results in really weird | 178 | // NOTE: use of CONNECTTIMEOUT without also |
178 | // crashes on my system! | 179 | // setting NOSIGNAL results in really weird |
179 | curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1); | 180 | // crashes on my system! |
180 | curl_easy_perform (c); | 181 | curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1); |
181 | curl_easy_cleanup (c); | 182 | curl_easy_perform (c); |
182 | } | 183 | curl_easy_cleanup (c); |
183 | fprintf(stderr, "\n"); | 184 | } |
184 | zzuf_socat_stop(); | 185 | fprintf (stderr, "\n"); |
186 | zzuf_socat_stop (); | ||
185 | MHD_stop_daemon (d); | 187 | MHD_stop_daemon (d); |
186 | return 0; | 188 | return 0; |
187 | } | 189 | } |
@@ -209,7 +211,7 @@ testExternalGet () | |||
209 | cbc.buf = buf; | 211 | cbc.buf = buf; |
210 | cbc.size = 2048; | 212 | cbc.size = 2048; |
211 | cbc.pos = 0; | 213 | cbc.pos = 0; |
212 | d = MHD_start_daemon (MHD_NO_FLAG /* | MHD_USE_DEBUG*/, | 214 | d = MHD_start_daemon (MHD_NO_FLAG /* | MHD_USE_DEBUG */ , |
213 | 11080, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); | 215 | 11080, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); |
214 | if (d == NULL) | 216 | if (d == NULL) |
215 | return 256; | 217 | return 256; |
@@ -220,82 +222,83 @@ testExternalGet () | |||
220 | MHD_stop_daemon (d); | 222 | MHD_stop_daemon (d); |
221 | return 512; | 223 | return 512; |
222 | } | 224 | } |
223 | zzuf_socat_start(); | 225 | zzuf_socat_start (); |
224 | for (i=0;i<LOOP_COUNT;i++) { | 226 | for (i = 0; i < LOOP_COUNT; i++) |
225 | fprintf(stderr, "."); | 227 | { |
226 | c = curl_easy_init (); | 228 | fprintf (stderr, "."); |
227 | curl_easy_setopt (c, CURLOPT_URL, "http://localhost:11081/hello_world"); | 229 | c = curl_easy_init (); |
228 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); | 230 | curl_easy_setopt (c, CURLOPT_URL, "http://localhost:11081/hello_world"); |
229 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); | 231 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); |
230 | curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); | 232 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); |
231 | if (oneone) | 233 | curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); |
232 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); | 234 | if (oneone) |
233 | else | 235 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); |
234 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); | 236 | else |
235 | curl_easy_setopt (c, CURLOPT_TIMEOUT_MS, CURL_TIMEOUT); | 237 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); |
236 | curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT_MS, CURL_TIMEOUT); | 238 | curl_easy_setopt (c, CURLOPT_TIMEOUT_MS, CURL_TIMEOUT); |
237 | // NOTE: use of CONNECTTIMEOUT without also | 239 | curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT_MS, CURL_TIMEOUT); |
238 | // setting NOSIGNAL results in really weird | 240 | // NOTE: use of CONNECTTIMEOUT without also |
239 | // crashes on my system! | 241 | // setting NOSIGNAL results in really weird |
240 | curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1); | 242 | // crashes on my system! |
241 | mret = curl_multi_add_handle (multi, c); | 243 | curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1); |
242 | if (mret != CURLM_OK) | 244 | mret = curl_multi_add_handle (multi, c); |
243 | { | 245 | if (mret != CURLM_OK) |
244 | curl_multi_cleanup (multi); | 246 | { |
245 | curl_easy_cleanup (c); | 247 | curl_multi_cleanup (multi); |
246 | zzuf_socat_stop(); | 248 | curl_easy_cleanup (c); |
247 | MHD_stop_daemon (d); | 249 | zzuf_socat_stop (); |
248 | return 1024; | 250 | MHD_stop_daemon (d); |
249 | } | 251 | return 1024; |
250 | start = time (NULL); | 252 | } |
251 | while ((time (NULL) - start < 5) && (c != NULL)) | 253 | start = time (NULL); |
252 | { | 254 | while ((time (NULL) - start < 5) && (c != NULL)) |
253 | max = 0; | 255 | { |
254 | FD_ZERO (&rs); | 256 | max = 0; |
255 | FD_ZERO (&ws); | 257 | FD_ZERO (&rs); |
256 | FD_ZERO (&es); | 258 | FD_ZERO (&ws); |
257 | curl_multi_perform (multi, &running); | 259 | FD_ZERO (&es); |
258 | mret = curl_multi_fdset (multi, &rs, &ws, &es, &max); | 260 | curl_multi_perform (multi, &running); |
259 | if (mret != CURLM_OK) | 261 | mret = curl_multi_fdset (multi, &rs, &ws, &es, &max); |
260 | { | 262 | if (mret != CURLM_OK) |
261 | curl_multi_remove_handle (multi, c); | 263 | { |
262 | curl_multi_cleanup (multi); | 264 | curl_multi_remove_handle (multi, c); |
263 | curl_easy_cleanup (c); | 265 | curl_multi_cleanup (multi); |
264 | zzuf_socat_stop(); | 266 | curl_easy_cleanup (c); |
265 | MHD_stop_daemon (d); | 267 | zzuf_socat_stop (); |
266 | return 2048; | 268 | MHD_stop_daemon (d); |
267 | } | 269 | return 2048; |
268 | if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &max)) | 270 | } |
269 | { | 271 | if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &max)) |
270 | curl_multi_remove_handle (multi, c); | 272 | { |
271 | curl_multi_cleanup (multi); | 273 | curl_multi_remove_handle (multi, c); |
272 | curl_easy_cleanup (c); | 274 | curl_multi_cleanup (multi); |
273 | zzuf_socat_stop(); | 275 | curl_easy_cleanup (c); |
274 | MHD_stop_daemon (d); | 276 | zzuf_socat_stop (); |
275 | return 4096; | 277 | MHD_stop_daemon (d); |
276 | } | 278 | return 4096; |
277 | tv.tv_sec = 0; | 279 | } |
278 | tv.tv_usec = 1000; | 280 | tv.tv_sec = 0; |
279 | select (max + 1, &rs, &ws, &es, &tv); | 281 | tv.tv_usec = 1000; |
280 | curl_multi_perform (multi, &running); | 282 | select (max + 1, &rs, &ws, &es, &tv); |
281 | if (running == 0) | 283 | curl_multi_perform (multi, &running); |
282 | { | 284 | if (running == 0) |
283 | curl_multi_info_read (multi, &running); | 285 | { |
284 | curl_multi_remove_handle (multi, c); | 286 | curl_multi_info_read (multi, &running); |
285 | curl_easy_cleanup (c); | 287 | curl_multi_remove_handle (multi, c); |
286 | c = NULL; | 288 | curl_easy_cleanup (c); |
287 | } | 289 | c = NULL; |
288 | MHD_run (d); | 290 | } |
289 | } | 291 | MHD_run (d); |
290 | if (c != NULL) | 292 | } |
291 | { | 293 | if (c != NULL) |
292 | curl_multi_remove_handle (multi, c); | 294 | { |
293 | curl_easy_cleanup (c); | 295 | curl_multi_remove_handle (multi, c); |
294 | } | 296 | curl_easy_cleanup (c); |
295 | } | 297 | } |
296 | fprintf(stderr, "\n"); | 298 | } |
299 | fprintf (stderr, "\n"); | ||
297 | curl_multi_cleanup (multi); | 300 | curl_multi_cleanup (multi); |
298 | zzuf_socat_stop(); | 301 | zzuf_socat_stop (); |
299 | MHD_stop_daemon (d); | 302 | MHD_stop_daemon (d); |
300 | return 0; | 303 | return 0; |
301 | } | 304 | } |
@@ -312,7 +315,7 @@ main (int argc, char *const *argv) | |||
312 | return 2; | 315 | return 2; |
313 | errorCount += testInternalGet (); | 316 | errorCount += testInternalGet (); |
314 | errorCount += testMultithreadedGet (); | 317 | errorCount += testMultithreadedGet (); |
315 | errorCount += testExternalGet (); | 318 | errorCount += testExternalGet (); |
316 | if (errorCount != 0) | 319 | if (errorCount != 0) |
317 | fprintf (stderr, "Error (code: %u)\n", errorCount); | 320 | fprintf (stderr, "Error (code: %u)\n", errorCount); |
318 | curl_global_cleanup (); | 321 | curl_global_cleanup (); |