diff options
author | Christian Grothoff <christian@grothoff.org> | 2008-04-13 02:54:58 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2008-04-13 02:54:58 +0000 |
commit | 72c08272fdbb426830363b0903224241157deb18 (patch) | |
tree | 7be7c5198f18edfe4b441744ff2e6ea83b896123 /src/testzzuf | |
parent | 359fcdda235f8ce9c625e1789e6b22bb30d592fd (diff) | |
download | libmicrohttpd-72c08272fdbb426830363b0903224241157deb18.tar.gz libmicrohttpd-72c08272fdbb426830363b0903224241157deb18.zip |
formatting
Diffstat (limited to 'src/testzzuf')
-rw-r--r-- | src/testzzuf/daemontest_get.c | 253 | ||||
-rw-r--r-- | src/testzzuf/daemontest_get_chunked.c | 235 | ||||
-rw-r--r-- | src/testzzuf/daemontest_large_put.c | 70 | ||||
-rw-r--r-- | src/testzzuf/socat.c | 71 |
4 files changed, 318 insertions, 311 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 (); |
diff --git a/src/testzzuf/daemontest_get_chunked.c b/src/testzzuf/daemontest_get_chunked.c index 4110d874..ca94beb0 100644 --- a/src/testzzuf/daemontest_get_chunked.c +++ b/src/testzzuf/daemontest_get_chunked.c | |||
@@ -139,30 +139,31 @@ testInternalGet () | |||
139 | cbc.buf = buf; | 139 | cbc.buf = buf; |
140 | cbc.size = 2048; | 140 | cbc.size = 2048; |
141 | cbc.pos = 0; | 141 | cbc.pos = 0; |
142 | d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY /* | MHD_USE_DEBUG */, | 142 | d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY /* | MHD_USE_DEBUG */ , |
143 | 11080, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); | 143 | 11080, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); |
144 | if (d == NULL) | 144 | if (d == NULL) |
145 | return 1; | 145 | return 1; |
146 | zzuf_socat_start(); | 146 | zzuf_socat_start (); |
147 | for (i=0;i<LOOP_COUNT;i++) { | 147 | for (i = 0; i < LOOP_COUNT; i++) |
148 | fprintf(stderr, "."); | 148 | { |
149 | c = curl_easy_init (); | 149 | fprintf (stderr, "."); |
150 | curl_easy_setopt (c, CURLOPT_URL, "http://localhost:11081/hello_world"); | 150 | c = curl_easy_init (); |
151 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); | 151 | curl_easy_setopt (c, CURLOPT_URL, "http://localhost:11081/hello_world"); |
152 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); | 152 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); |
153 | curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); | 153 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); |
154 | curl_easy_setopt (c, CURLOPT_TIMEOUT_MS, CURL_TIMEOUT); | 154 | curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); |
155 | curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT_MS, CURL_TIMEOUT); | 155 | curl_easy_setopt (c, CURLOPT_TIMEOUT_MS, CURL_TIMEOUT); |
156 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); | 156 | curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT_MS, CURL_TIMEOUT); |
157 | // NOTE: use of CONNECTTIMEOUT without also | 157 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); |
158 | // setting NOSIGNAL results in really weird | 158 | // NOTE: use of CONNECTTIMEOUT without also |
159 | // crashes on my system! | 159 | // setting NOSIGNAL results in really weird |
160 | curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1); | 160 | // crashes on my system! |
161 | curl_easy_perform (c); | 161 | curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1); |
162 | curl_easy_cleanup (c); | 162 | curl_easy_perform (c); |
163 | } | 163 | curl_easy_cleanup (c); |
164 | fprintf(stderr, "\n"); | 164 | } |
165 | zzuf_socat_stop(); | 165 | fprintf (stderr, "\n"); |
166 | zzuf_socat_stop (); | ||
166 | MHD_stop_daemon (d); | 167 | MHD_stop_daemon (d); |
167 | return 0; | 168 | return 0; |
168 | } | 169 | } |
@@ -175,34 +176,35 @@ testMultithreadedGet () | |||
175 | char buf[2048]; | 176 | char buf[2048]; |
176 | struct CBC cbc; | 177 | struct CBC cbc; |
177 | int i; | 178 | int i; |
178 | 179 | ||
179 | cbc.buf = buf; | 180 | cbc.buf = buf; |
180 | cbc.size = 2048; | 181 | cbc.size = 2048; |
181 | cbc.pos = 0; | 182 | cbc.pos = 0; |
182 | d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION /* | MHD_USE_DEBUG */, | 183 | d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION /* | MHD_USE_DEBUG */ , |
183 | 11080, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); | 184 | 11080, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); |
184 | if (d == NULL) | 185 | if (d == NULL) |
185 | return 16; | 186 | return 16; |
186 | zzuf_socat_start(); | 187 | zzuf_socat_start (); |
187 | for (i=0;i<LOOP_COUNT;i++) { | 188 | for (i = 0; i < LOOP_COUNT; i++) |
188 | fprintf(stderr, "."); | 189 | { |
189 | c = curl_easy_init (); | 190 | fprintf (stderr, "."); |
190 | curl_easy_setopt (c, CURLOPT_URL, "http://localhost:11081/hello_world"); | 191 | c = curl_easy_init (); |
191 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); | 192 | curl_easy_setopt (c, CURLOPT_URL, "http://localhost:11081/hello_world"); |
192 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); | 193 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); |
193 | curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); | 194 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); |
194 | curl_easy_setopt (c, CURLOPT_TIMEOUT_MS, CURL_TIMEOUT); | 195 | curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); |
195 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); | 196 | curl_easy_setopt (c, CURLOPT_TIMEOUT_MS, CURL_TIMEOUT); |
196 | curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT_MS, CURL_TIMEOUT); | 197 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); |
197 | // NOTE: use of CONNECTTIMEOUT without also | 198 | curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT_MS, CURL_TIMEOUT); |
198 | // setting NOSIGNAL results in really weird | 199 | // NOTE: use of CONNECTTIMEOUT without also |
199 | // crashes on my system! | 200 | // setting NOSIGNAL results in really weird |
200 | curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1); | 201 | // crashes on my system! |
201 | curl_easy_perform (c); | 202 | curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1); |
202 | curl_easy_cleanup (c); | 203 | curl_easy_perform (c); |
203 | } | 204 | curl_easy_cleanup (c); |
204 | fprintf(stderr, "\n"); | 205 | } |
205 | zzuf_socat_stop(); | 206 | fprintf (stderr, "\n"); |
207 | zzuf_socat_stop (); | ||
206 | MHD_stop_daemon (d); | 208 | MHD_stop_daemon (d); |
207 | return 0; | 209 | return 0; |
208 | } | 210 | } |
@@ -230,7 +232,7 @@ testExternalGet () | |||
230 | cbc.buf = buf; | 232 | cbc.buf = buf; |
231 | cbc.size = 2048; | 233 | cbc.size = 2048; |
232 | cbc.pos = 0; | 234 | cbc.pos = 0; |
233 | d = MHD_start_daemon (MHD_NO_FLAG /* | MHD_USE_DEBUG */, | 235 | d = MHD_start_daemon (MHD_NO_FLAG /* | MHD_USE_DEBUG */ , |
234 | 11080, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); | 236 | 11080, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); |
235 | if (d == NULL) | 237 | if (d == NULL) |
236 | return 256; | 238 | return 256; |
@@ -241,79 +243,80 @@ testExternalGet () | |||
241 | MHD_stop_daemon (d); | 243 | MHD_stop_daemon (d); |
242 | return 512; | 244 | return 512; |
243 | } | 245 | } |
244 | zzuf_socat_start(); | 246 | zzuf_socat_start (); |
245 | for (i=0;i<LOOP_COUNT;i++) { | 247 | for (i = 0; i < LOOP_COUNT; i++) |
246 | fprintf(stderr, "."); | 248 | { |
247 | c = curl_easy_init (); | 249 | fprintf (stderr, "."); |
248 | curl_easy_setopt (c, CURLOPT_URL, "http://localhost:11081/hello_world"); | 250 | c = curl_easy_init (); |
249 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); | 251 | curl_easy_setopt (c, CURLOPT_URL, "http://localhost:11081/hello_world"); |
250 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); | 252 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); |
251 | curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); | 253 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); |
252 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); | 254 | curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); |
253 | curl_easy_setopt (c, CURLOPT_TIMEOUT_MS, CURL_TIMEOUT); | 255 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); |
254 | curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT_MS, CURL_TIMEOUT); | 256 | curl_easy_setopt (c, CURLOPT_TIMEOUT_MS, CURL_TIMEOUT); |
255 | // NOTE: use of CONNECTTIMEOUT without also | 257 | curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT_MS, CURL_TIMEOUT); |
256 | // setting NOSIGNAL results in really weird | 258 | // NOTE: use of CONNECTTIMEOUT without also |
257 | // crashes on my system! | 259 | // setting NOSIGNAL results in really weird |
258 | curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1); | 260 | // crashes on my system! |
259 | mret = curl_multi_add_handle (multi, c); | 261 | curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1); |
260 | if (mret != CURLM_OK) | 262 | mret = curl_multi_add_handle (multi, c); |
261 | { | 263 | if (mret != CURLM_OK) |
262 | curl_multi_cleanup (multi); | 264 | { |
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 1024; | 268 | MHD_stop_daemon (d); |
267 | } | 269 | return 1024; |
268 | start = time (NULL); | 270 | } |
269 | while ((time (NULL) - start < 5) && (c != NULL)) | 271 | start = time (NULL); |
270 | { | 272 | while ((time (NULL) - start < 5) && (c != NULL)) |
271 | max = 0; | 273 | { |
272 | FD_ZERO (&rs); | 274 | max = 0; |
273 | FD_ZERO (&ws); | 275 | FD_ZERO (&rs); |
274 | FD_ZERO (&es); | 276 | FD_ZERO (&ws); |
275 | curl_multi_perform (multi, &running); | 277 | FD_ZERO (&es); |
276 | mret = curl_multi_fdset (multi, &rs, &ws, &es, &max); | 278 | curl_multi_perform (multi, &running); |
277 | if (mret != CURLM_OK) | 279 | mret = curl_multi_fdset (multi, &rs, &ws, &es, &max); |
278 | { | 280 | if (mret != CURLM_OK) |
279 | curl_multi_remove_handle (multi, c); | 281 | { |
280 | curl_multi_cleanup (multi); | 282 | curl_multi_remove_handle (multi, c); |
281 | curl_easy_cleanup (c); | 283 | curl_multi_cleanup (multi); |
282 | zzuf_socat_stop(); | 284 | curl_easy_cleanup (c); |
283 | MHD_stop_daemon (d); | 285 | zzuf_socat_stop (); |
284 | return 2048; | 286 | MHD_stop_daemon (d); |
285 | } | 287 | return 2048; |
286 | if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &max)) | 288 | } |
287 | { | 289 | if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &max)) |
288 | curl_multi_remove_handle (multi, c); | 290 | { |
289 | curl_multi_cleanup (multi); | 291 | curl_multi_remove_handle (multi, c); |
290 | curl_easy_cleanup (c); | 292 | curl_multi_cleanup (multi); |
291 | zzuf_socat_stop(); | 293 | curl_easy_cleanup (c); |
292 | MHD_stop_daemon (d); | 294 | zzuf_socat_stop (); |
293 | return 4096; | 295 | MHD_stop_daemon (d); |
294 | } | 296 | return 4096; |
295 | tv.tv_sec = 0; | 297 | } |
296 | tv.tv_usec = 1000; | 298 | tv.tv_sec = 0; |
297 | select (max + 1, &rs, &ws, &es, &tv); | 299 | tv.tv_usec = 1000; |
298 | curl_multi_perform (multi, &running); | 300 | select (max + 1, &rs, &ws, &es, &tv); |
299 | if (running == 0) | 301 | curl_multi_perform (multi, &running); |
300 | { | 302 | if (running == 0) |
301 | curl_multi_info_read (multi, &running); | 303 | { |
302 | curl_multi_remove_handle (multi, c); | 304 | curl_multi_info_read (multi, &running); |
303 | curl_easy_cleanup (c); | 305 | curl_multi_remove_handle (multi, c); |
304 | c = NULL; | 306 | curl_easy_cleanup (c); |
305 | } | 307 | c = NULL; |
306 | MHD_run (d); | 308 | } |
307 | } | 309 | MHD_run (d); |
308 | if (c != NULL) | 310 | } |
309 | { | 311 | if (c != NULL) |
310 | curl_multi_remove_handle (multi, c); | 312 | { |
311 | curl_easy_cleanup (c); | 313 | curl_multi_remove_handle (multi, c); |
312 | } | 314 | curl_easy_cleanup (c); |
313 | } | 315 | } |
314 | fprintf(stderr, "\n"); | 316 | } |
317 | fprintf (stderr, "\n"); | ||
315 | curl_multi_cleanup (multi); | 318 | curl_multi_cleanup (multi); |
316 | zzuf_socat_stop(); | 319 | zzuf_socat_stop (); |
317 | MHD_stop_daemon (d); | 320 | MHD_stop_daemon (d); |
318 | return 0; | 321 | return 0; |
319 | } | 322 | } |
diff --git a/src/testzzuf/daemontest_large_put.c b/src/testzzuf/daemontest_large_put.c index b0c7bf37..72399c72 100644 --- a/src/testzzuf/daemontest_large_put.c +++ b/src/testzzuf/daemontest_large_put.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libmicrohttpd | 2 | This file is part of libmicrohttpd |
3 | (C) 2007 Christian Grothoff | 3 | (C) 2007, 2008 Christian Grothoff |
4 | 4 | ||
5 | libmicrohttpd is free software; you can redistribute it and/or modify | 5 | libmicrohttpd is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
@@ -35,6 +35,18 @@ | |||
35 | #include <unistd.h> | 35 | #include <unistd.h> |
36 | #endif | 36 | #endif |
37 | 37 | ||
38 | #include "socat.c" | ||
39 | |||
40 | /** | ||
41 | * A larger loop count will run more random tests -- | ||
42 | * which would be good, except that it may take too | ||
43 | * long for most user's patience. So this small | ||
44 | * value is the default. | ||
45 | */ | ||
46 | #define LOOP_COUNT 10 | ||
47 | |||
48 | #define CURL_TIMEOUT 50L | ||
49 | |||
38 | static int oneone; | 50 | static int oneone; |
39 | 51 | ||
40 | /** | 52 | /** |
@@ -133,8 +145,8 @@ testInternalPut () | |||
133 | struct CBC cbc; | 145 | struct CBC cbc; |
134 | unsigned int pos = 0; | 146 | unsigned int pos = 0; |
135 | int done_flag = 0; | 147 | int done_flag = 0; |
136 | CURLcode errornum; | ||
137 | char buf[2048]; | 148 | char buf[2048]; |
149 | int i; | ||
138 | 150 | ||
139 | cbc.buf = buf; | 151 | cbc.buf = buf; |
140 | cbc.size = 2048; | 152 | cbc.size = 2048; |
@@ -144,40 +156,34 @@ testInternalPut () | |||
144 | NULL, NULL, &ahc_echo, &done_flag, MHD_OPTION_END); | 156 | NULL, NULL, &ahc_echo, &done_flag, MHD_OPTION_END); |
145 | if (d == NULL) | 157 | if (d == NULL) |
146 | return 1; | 158 | return 1; |
147 | c = curl_easy_init (); | 159 | for (i = 0; i < LOOP_COUNT; i++) |
148 | curl_easy_setopt (c, CURLOPT_URL, "http://localhost:1080/hello_world"); | ||
149 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); | ||
150 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); | ||
151 | curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer); | ||
152 | curl_easy_setopt (c, CURLOPT_READDATA, &pos); | ||
153 | curl_easy_setopt (c, CURLOPT_UPLOAD, 1L); | ||
154 | curl_easy_setopt (c, CURLOPT_INFILESIZE, (long) PUT_SIZE); | ||
155 | curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); | ||
156 | curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); | ||
157 | if (oneone) | ||
158 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); | ||
159 | else | ||
160 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); | ||
161 | curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 15L); | ||
162 | // NOTE: use of CONNECTTIMEOUT without also | ||
163 | // setting NOSIGNAL results in really weird | ||
164 | // crashes on my system! | ||
165 | curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1); | ||
166 | if (CURLE_OK != (errornum = curl_easy_perform (c))) | ||
167 | { | 160 | { |
168 | fprintf (stderr, | 161 | fprintf (stderr, "."); |
169 | "curl_easy_perform failed: `%s'\n", | 162 | |
170 | curl_easy_strerror (errornum)); | 163 | c = curl_easy_init (); |
164 | curl_easy_setopt (c, CURLOPT_URL, "http://localhost:1080/hello_world"); | ||
165 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); | ||
166 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); | ||
167 | curl_easy_setopt (c, CURLOPT_READFUNCTION, &putBuffer); | ||
168 | curl_easy_setopt (c, CURLOPT_READDATA, &pos); | ||
169 | curl_easy_setopt (c, CURLOPT_UPLOAD, 1L); | ||
170 | curl_easy_setopt (c, CURLOPT_INFILESIZE, (long) PUT_SIZE); | ||
171 | curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); | ||
172 | curl_easy_setopt (c, CURLOPT_TIMEOUT_MS, CURL_TIMEOUT); | ||
173 | if (oneone) | ||
174 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); | ||
175 | else | ||
176 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); | ||
177 | curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT_MS, CURL_TIMEOUT); | ||
178 | // NOTE: use of CONNECTTIMEOUT without also | ||
179 | // setting NOSIGNAL results in really weird | ||
180 | // crashes on my system! | ||
181 | curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1); | ||
182 | curl_easy_perform (c); | ||
171 | curl_easy_cleanup (c); | 183 | curl_easy_cleanup (c); |
172 | MHD_stop_daemon (d); | ||
173 | return 2; | ||
174 | } | 184 | } |
175 | curl_easy_cleanup (c); | 185 | fprintf (stderr, "\n"); |
176 | MHD_stop_daemon (d); | 186 | MHD_stop_daemon (d); |
177 | if (cbc.pos != strlen ("/hello_world")) | ||
178 | return 4; | ||
179 | if (0 != strncmp ("/hello_world", cbc.buf, strlen ("/hello_world"))) | ||
180 | return 8; | ||
181 | return 0; | 187 | return 0; |
182 | } | 188 | } |
183 | 189 | ||
diff --git a/src/testzzuf/socat.c b/src/testzzuf/socat.c index b8948575..0933010b 100644 --- a/src/testzzuf/socat.c +++ b/src/testzzuf/socat.c | |||
@@ -33,9 +33,10 @@ | |||
33 | static pid_t zzuf_pid; | 33 | static pid_t zzuf_pid; |
34 | 34 | ||
35 | static void | 35 | static void |
36 | zzuf_socat_start() { | 36 | zzuf_socat_start () |
37 | { | ||
37 | int status; | 38 | int status; |
38 | char * const args[] = { | 39 | char *const args[] = { |
39 | "zzuf", | 40 | "zzuf", |
40 | "--ratio=0.0:0.75", | 41 | "--ratio=0.0:0.75", |
41 | "-n", | 42 | "-n", |
@@ -45,54 +46,48 @@ zzuf_socat_start() { | |||
45 | "TCP4:127.0.0.1:11080", | 46 | "TCP4:127.0.0.1:11080", |
46 | NULL, | 47 | NULL, |
47 | }; | 48 | }; |
48 | zzuf_pid = fork(); | 49 | zzuf_pid = fork (); |
49 | if (zzuf_pid == -1) { | 50 | if (zzuf_pid == -1) |
50 | fprintf(stderr, | 51 | { |
51 | "fork failed: %s\n", | 52 | fprintf (stderr, "fork failed: %s\n", strerror (errno)); |
52 | strerror(errno)); | 53 | exit (1); |
53 | exit(1); | 54 | } |
54 | } | ||
55 | if (zzuf_pid != 0) | 55 | if (zzuf_pid != 0) |
56 | { | 56 | { |
57 | sleep(1); /* allow zzuf and socat to start */ | 57 | sleep (1); /* allow zzuf and socat to start */ |
58 | status = 0; | 58 | status = 0; |
59 | if (0 < waitpid(zzuf_pid, &status, WNOHANG)) | 59 | if (0 < waitpid (zzuf_pid, &status, WNOHANG)) |
60 | { | 60 | { |
61 | if (WIFEXITED(status)) | 61 | if (WIFEXITED (status)) |
62 | fprintf(stderr, | 62 | fprintf (stderr, |
63 | "zzuf died with status code %d!\n", | 63 | "zzuf died with status code %d!\n", |
64 | WEXITSTATUS(status)); | 64 | WEXITSTATUS (status)); |
65 | if (WIFSIGNALED(status)) | 65 | if (WIFSIGNALED (status)) |
66 | fprintf(stderr, | 66 | fprintf (stderr, |
67 | "zzuf died from signal %d!\n", | 67 | "zzuf died from signal %d!\n", WTERMSIG (status)); |
68 | WTERMSIG(status)); | 68 | exit (1); |
69 | exit(1); | 69 | } |
70 | } | ||
71 | return; | 70 | return; |
72 | } | 71 | } |
73 | setpgrp(); | 72 | setpgrp (); |
74 | execvp("zzuf", | 73 | execvp ("zzuf", args); |
75 | args); | 74 | fprintf (stderr, "execution of `zzuf' failed: %s\n", strerror (errno)); |
76 | fprintf(stderr, | 75 | zzuf_pid = 0; /* fork failed */ |
77 | "execution of `zzuf' failed: %s\n", | 76 | exit (1); |
78 | strerror(errno)); | ||
79 | zzuf_pid = 0; /* fork failed */ | ||
80 | exit(1); | ||
81 | } | 77 | } |
82 | 78 | ||
83 | 79 | ||
84 | static void | 80 | static void |
85 | zzuf_socat_stop() { | 81 | zzuf_socat_stop () |
82 | { | ||
86 | int status; | 83 | int status; |
87 | if (zzuf_pid != 0) | 84 | if (zzuf_pid != 0) |
88 | { | 85 | { |
89 | if (0 != killpg(zzuf_pid, SIGINT)) | 86 | if (0 != killpg (zzuf_pid, SIGINT)) |
90 | fprintf(stderr, | 87 | fprintf (stderr, "Failed to killpg: %s\n", strerror (errno)); |
91 | "Failed to killpg: %s\n", | 88 | kill (zzuf_pid, SIGINT); |
92 | strerror(errno)); | 89 | waitpid (zzuf_pid, &status, 0); |
93 | kill(zzuf_pid, SIGINT); | 90 | sleep (1); /* allow socat to also die in peace */ |
94 | waitpid(zzuf_pid, &status, 0); | ||
95 | sleep(1); /* allow socat to also die in peace */ | ||
96 | } | 91 | } |
97 | } | 92 | } |
98 | 93 | ||