aboutsummaryrefslogtreecommitdiff
path: root/src/testcurl/test_post_loop.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testcurl/test_post_loop.c')
-rw-r--r--src/testcurl/test_post_loop.c88
1 files changed, 80 insertions, 8 deletions
diff --git a/src/testcurl/test_post_loop.c b/src/testcurl/test_post_loop.c
index 5495fd5a..9a4c6db1 100644
--- a/src/testcurl/test_post_loop.c
+++ b/src/testcurl/test_post_loop.c
@@ -116,13 +116,31 @@ testInternalPost ()
116 CURLcode errornum; 116 CURLcode errornum;
117 int i; 117 int i;
118 char url[1024]; 118 char url[1024];
119 int port;
120
121 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
122 port = 0;
123 else
124 {
125 port = 1350;
126 if (oneone)
127 port += 10;
128 }
119 129
120 cbc.buf = buf; 130 cbc.buf = buf;
121 cbc.size = 2048; 131 cbc.size = 2048;
122 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, 132 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG,
123 1080, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_END); 133 port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_END);
124 if (d == NULL) 134 if (d == NULL)
125 return 1; 135 return 1;
136 if (0 == port)
137 {
138 const union MHD_DaemonInfo *dinfo;
139 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
140 if (NULL == dinfo || 0 == dinfo->port)
141 { MHD_stop_daemon (d); return 32; }
142 port = (int)dinfo->port;
143 }
126 for (i = 0; i < LOOPCOUNT; i++) 144 for (i = 0; i < LOOPCOUNT; i++)
127 { 145 {
128 if (99 == i % 100) 146 if (99 == i % 100)
@@ -130,7 +148,7 @@ testInternalPost ()
130 c = curl_easy_init (); 148 c = curl_easy_init ();
131 cbc.pos = 0; 149 cbc.pos = 0;
132 buf[0] = '\0'; 150 buf[0] = '\0';
133 sprintf (url, "http://127.0.0.1:1080/hw%d", i); 151 sprintf (url, "http://127.0.0.1:%d/hw%d", port, i);
134 curl_easy_setopt (c, CURLOPT_URL, url); 152 curl_easy_setopt (c, CURLOPT_URL, url);
135 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 153 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
136 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 154 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
@@ -180,13 +198,31 @@ testMultithreadedPost ()
180 CURLcode errornum; 198 CURLcode errornum;
181 int i; 199 int i;
182 char url[1024]; 200 char url[1024];
201 int port;
202
203 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
204 port = 0;
205 else
206 {
207 port = 1351;
208 if (oneone)
209 port += 10;
210 }
183 211
184 cbc.buf = buf; 212 cbc.buf = buf;
185 cbc.size = 2048; 213 cbc.size = 2048;
186 d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, 214 d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG,
187 1081, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_END); 215 port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_END);
188 if (d == NULL) 216 if (d == NULL)
189 return 16; 217 return 16;
218 if (0 == port)
219 {
220 const union MHD_DaemonInfo *dinfo;
221 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
222 if (NULL == dinfo || 0 == dinfo->port)
223 { MHD_stop_daemon (d); return 32; }
224 port = (int)dinfo->port;
225 }
190 for (i = 0; i < LOOPCOUNT; i++) 226 for (i = 0; i < LOOPCOUNT; i++)
191 { 227 {
192 if (99 == i % 100) 228 if (99 == i % 100)
@@ -194,7 +230,7 @@ testMultithreadedPost ()
194 c = curl_easy_init (); 230 c = curl_easy_init ();
195 cbc.pos = 0; 231 cbc.pos = 0;
196 buf[0] = '\0'; 232 buf[0] = '\0';
197 sprintf (url, "http://127.0.0.1:1081/hw%d", i); 233 sprintf (url, "http://127.0.0.1:%d/hw%d", port, i);
198 curl_easy_setopt (c, CURLOPT_URL, url); 234 curl_easy_setopt (c, CURLOPT_URL, url);
199 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 235 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
200 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 236 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
@@ -244,14 +280,32 @@ testMultithreadedPoolPost ()
244 CURLcode errornum; 280 CURLcode errornum;
245 int i; 281 int i;
246 char url[1024]; 282 char url[1024];
283 int port;
284
285 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
286 port = 0;
287 else
288 {
289 port = 1352;
290 if (oneone)
291 port += 10;
292 }
247 293
248 cbc.buf = buf; 294 cbc.buf = buf;
249 cbc.size = 2048; 295 cbc.size = 2048;
250 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, 296 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG,
251 1081, NULL, NULL, &ahc_echo, NULL, 297 port, NULL, NULL, &ahc_echo, NULL,
252 MHD_OPTION_THREAD_POOL_SIZE, CPU_COUNT, MHD_OPTION_END); 298 MHD_OPTION_THREAD_POOL_SIZE, CPU_COUNT, MHD_OPTION_END);
253 if (d == NULL) 299 if (d == NULL)
254 return 16; 300 return 16;
301 if (0 == port)
302 {
303 const union MHD_DaemonInfo *dinfo;
304 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
305 if (NULL == dinfo || 0 == dinfo->port)
306 { MHD_stop_daemon (d); return 32; }
307 port = (int)dinfo->port;
308 }
255 for (i = 0; i < LOOPCOUNT; i++) 309 for (i = 0; i < LOOPCOUNT; i++)
256 { 310 {
257 if (99 == i % 100) 311 if (99 == i % 100)
@@ -259,7 +313,7 @@ testMultithreadedPoolPost ()
259 c = curl_easy_init (); 313 c = curl_easy_init ();
260 cbc.pos = 0; 314 cbc.pos = 0;
261 buf[0] = '\0'; 315 buf[0] = '\0';
262 sprintf (url, "http://127.0.0.1:1081/hw%d", i); 316 sprintf (url, "http://127.0.0.1:%d/hw%d", port, i);
263 curl_easy_setopt (c, CURLOPT_URL, url); 317 curl_easy_setopt (c, CURLOPT_URL, url);
264 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 318 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
265 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 319 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
@@ -325,15 +379,33 @@ testExternalPost ()
325 unsigned long long timeout; 379 unsigned long long timeout;
326 long ctimeout; 380 long ctimeout;
327 char url[1024]; 381 char url[1024];
382 int port;
383
384 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
385 port = 0;
386 else
387 {
388 port = 1353;
389 if (oneone)
390 port += 10;
391 }
328 392
329 multi = NULL; 393 multi = NULL;
330 cbc.buf = buf; 394 cbc.buf = buf;
331 cbc.size = 2048; 395 cbc.size = 2048;
332 cbc.pos = 0; 396 cbc.pos = 0;
333 d = MHD_start_daemon (MHD_USE_ERROR_LOG, 397 d = MHD_start_daemon (MHD_USE_ERROR_LOG,
334 1082, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_END); 398 port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_END);
335 if (d == NULL) 399 if (d == NULL)
336 return 256; 400 return 256;
401 if (0 == port)
402 {
403 const union MHD_DaemonInfo *dinfo;
404 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
405 if (NULL == dinfo || 0 == dinfo->port)
406 { MHD_stop_daemon (d); return 32; }
407 port = (int)dinfo->port;
408 }
337 multi = curl_multi_init (); 409 multi = curl_multi_init ();
338 if (multi == NULL) 410 if (multi == NULL)
339 { 411 {
@@ -347,7 +419,7 @@ testExternalPost ()
347 c = curl_easy_init (); 419 c = curl_easy_init ();
348 cbc.pos = 0; 420 cbc.pos = 0;
349 buf[0] = '\0'; 421 buf[0] = '\0';
350 sprintf (url, "http://127.0.0.1:1082/hw%d", i); 422 sprintf (url, "http://127.0.0.1:%d/hw%d", port, i);
351 curl_easy_setopt (c, CURLOPT_URL, url); 423 curl_easy_setopt (c, CURLOPT_URL, url);
352 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 424 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
353 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 425 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);