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.c36
1 files changed, 27 insertions, 9 deletions
diff --git a/src/testcurl/test_post_loop.c b/src/testcurl/test_post_loop.c
index 5ed57431..6da06b45 100644
--- a/src/testcurl/test_post_loop.c
+++ b/src/testcurl/test_post_loop.c
@@ -93,7 +93,7 @@ ahc_echo (void *cls,
93 { 93 {
94 if (*mptr != &marker) 94 if (*mptr != &marker)
95 abort (); 95 abort ();
96 response = MHD_create_response_from_buffer (2, "OK", 96 response = MHD_create_response_from_buffer (2, "OK",
97 MHD_RESPMEM_PERSISTENT); 97 MHD_RESPMEM_PERSISTENT);
98 ret = MHD_queue_response (connection, MHD_HTTP_OK, response); 98 ret = MHD_queue_response (connection, MHD_HTTP_OK, response);
99 MHD_destroy_response (response); 99 MHD_destroy_response (response);
@@ -150,7 +150,11 @@ testInternalPost ()
150 c = curl_easy_init (); 150 c = curl_easy_init ();
151 cbc.pos = 0; 151 cbc.pos = 0;
152 buf[0] = '\0'; 152 buf[0] = '\0';
153 sprintf (url, "http://127.0.0.1:%d/hw%d", port, i); 153 snprintf (url,
154 sizeof (url),
155 "http://127.0.0.1:%d/hw%d",
156 port,
157 i);
154 curl_easy_setopt (c, CURLOPT_URL, url); 158 curl_easy_setopt (c, CURLOPT_URL, url);
155 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 159 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
156 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 160 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
@@ -214,7 +218,9 @@ testMultithreadedPost ()
214 cbc.buf = buf; 218 cbc.buf = buf;
215 cbc.size = 2048; 219 cbc.size = 2048;
216 d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, 220 d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG,
217 port, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_END); 221 port, NULL, NULL,
222 &ahc_echo, NULL,
223 MHD_OPTION_END);
218 if (d == NULL) 224 if (d == NULL)
219 return 16; 225 return 16;
220 if (0 == port) 226 if (0 == port)
@@ -232,7 +238,11 @@ testMultithreadedPost ()
232 c = curl_easy_init (); 238 c = curl_easy_init ();
233 cbc.pos = 0; 239 cbc.pos = 0;
234 buf[0] = '\0'; 240 buf[0] = '\0';
235 sprintf (url, "http://127.0.0.1:%d/hw%d", port, i); 241 snprintf (url,
242 sizeof (url),
243 "http://127.0.0.1:%d/hw%d",
244 port,
245 i);
236 curl_easy_setopt (c, CURLOPT_URL, url); 246 curl_easy_setopt (c, CURLOPT_URL, url);
237 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 247 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
238 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 248 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
@@ -315,7 +325,11 @@ testMultithreadedPoolPost ()
315 c = curl_easy_init (); 325 c = curl_easy_init ();
316 cbc.pos = 0; 326 cbc.pos = 0;
317 buf[0] = '\0'; 327 buf[0] = '\0';
318 sprintf (url, "http://127.0.0.1:%d/hw%d", port, i); 328 snprintf (url,
329 sizeof (url),
330 "http://127.0.0.1:%d/hw%d",
331 port,
332 i);
319 curl_easy_setopt (c, CURLOPT_URL, url); 333 curl_easy_setopt (c, CURLOPT_URL, url);
320 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 334 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
321 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 335 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
@@ -421,7 +435,11 @@ testExternalPost ()
421 c = curl_easy_init (); 435 c = curl_easy_init ();
422 cbc.pos = 0; 436 cbc.pos = 0;
423 buf[0] = '\0'; 437 buf[0] = '\0';
424 sprintf (url, "http://127.0.0.1:%d/hw%d", port, i); 438 snprintf (url,
439 sizeof (url),
440 "http://127.0.0.1:%d/hw%d",
441 port,
442 i);
425 curl_easy_setopt (c, CURLOPT_URL, url); 443 curl_easy_setopt (c, CURLOPT_URL, url);
426 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 444 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
427 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 445 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
@@ -490,7 +508,7 @@ testExternalPost ()
490 fprintf (stderr, 508 fprintf (stderr,
491 "select failed: %s\n", 509 "select failed: %s\n",
492 strerror (errno)); 510 strerror (errno));
493 break; 511 break;
494 } 512 }
495 while (CURLM_CALL_MULTI_PERFORM == 513 while (CURLM_CALL_MULTI_PERFORM ==
496 curl_multi_perform (multi, &running)); 514 curl_multi_perform (multi, &running));
@@ -540,11 +558,11 @@ static unsigned long long start_time;
540 558
541 559
542/** 560/**
543 * Get the current timestamp 561 * Get the current timestamp
544 * 562 *
545 * @return current time in ms 563 * @return current time in ms
546 */ 564 */
547static unsigned long long 565static unsigned long long
548now () 566now ()
549{ 567{
550 struct timeval tv; 568 struct timeval tv;