aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEvgeny Grin (Karlson2k) <k2k@narod.ru>2022-04-28 17:19:54 +0300
committerEvgeny Grin (Karlson2k) <k2k@narod.ru>2022-04-28 19:06:46 +0300
commitba77b04c65c5b6b0bad204f8e08f986b5c215dc0 (patch)
tree71e79ab5177d0cbb1acfacbf680177236b87283b /src
parentc6eae238be6357a7e0b77298a0cdada4c63e80bc (diff)
downloadlibmicrohttpd-ba77b04c65c5b6b0bad204f8e08f986b5c215dc0.tar.gz
libmicrohttpd-ba77b04c65c5b6b0bad204f8e08f986b5c215dc0.zip
Replaced calls of MHD_get_timeout() in tests and examples
The calls were replaced with the calls of the new functions. Completely removed the usage of MHD_UNSIGNED_LONG_LONG.
Diffstat (limited to 'src')
-rw-r--r--src/examples/fileserver_example_external_select.c6
-rw-r--r--src/examples/post_example.c4
-rw-r--r--src/examples/suspend_resume_epoll.c12
-rw-r--r--src/microhttpd/test_client_put_stop.c3
-rw-r--r--src/microhttpd/test_set_panic.c3
-rw-r--r--src/microhttpd/test_upgrade.c32
-rw-r--r--src/microhttpd/test_upgrade_large.c32
-rw-r--r--src/testcurl/perf_get_concurrent.c10
-rw-r--r--src/testcurl/test_get_close_keep_alive.c3
-rw-r--r--src/testcurl/test_post_loop.c16
-rw-r--r--src/testcurl/test_toolarge.c3
-rw-r--r--src/testcurl/test_tricky.c3
12 files changed, 57 insertions, 70 deletions
diff --git a/src/examples/fileserver_example_external_select.c b/src/examples/fileserver_example_external_select.c
index cdd455ec..3c077413 100644
--- a/src/examples/fileserver_example_external_select.c
+++ b/src/examples/fileserver_example_external_select.c
@@ -134,7 +134,7 @@ main (int argc, char *const *argv)
134 fd_set ws; 134 fd_set ws;
135 fd_set es; 135 fd_set es;
136 MHD_socket max; 136 MHD_socket max;
137 MHD_UNSIGNED_LONG_LONG mhd_timeout; 137 uint64_t mhd_timeout;
138 138
139 if (argc != 3) 139 if (argc != 3)
140 { 140 {
@@ -157,9 +157,9 @@ main (int argc, char *const *argv)
157 FD_ZERO (&es); 157 FD_ZERO (&es);
158 if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &max)) 158 if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &max))
159 break; /* fatal internal error */ 159 break; /* fatal internal error */
160 if (MHD_get_timeout (d, &mhd_timeout) == MHD_YES) 160 if (MHD_get_timeout64 (d, &mhd_timeout) == MHD_YES)
161 { 161 {
162 if (((MHD_UNSIGNED_LONG_LONG) tv.tv_sec) < mhd_timeout / 1000LL) 162 if (((uint64_t) tv.tv_sec) < mhd_timeout / 1000LL)
163 { 163 {
164 tv.tv_sec = mhd_timeout / 1000LL; 164 tv.tv_sec = mhd_timeout / 1000LL;
165 tv.tv_usec = (mhd_timeout - (tv.tv_sec * 1000LL)) * 1000LL; 165 tv.tv_usec = (mhd_timeout - (tv.tv_sec * 1000LL)) * 1000LL;
diff --git a/src/examples/post_example.c b/src/examples/post_example.c
index 1134a331..709fc918 100644
--- a/src/examples/post_example.c
+++ b/src/examples/post_example.c
@@ -733,7 +733,7 @@ main (int argc, char *const *argv)
733 fd_set ws; 733 fd_set ws;
734 fd_set es; 734 fd_set es;
735 MHD_socket max; 735 MHD_socket max;
736 MHD_UNSIGNED_LONG_LONG mhd_timeout; 736 uint64_t mhd_timeout;
737 737
738 if (argc != 2) 738 if (argc != 2)
739 { 739 {
@@ -761,7 +761,7 @@ main (int argc, char *const *argv)
761 FD_ZERO (&es); 761 FD_ZERO (&es);
762 if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &max)) 762 if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &max))
763 break; /* fatal internal error */ 763 break; /* fatal internal error */
764 if (MHD_get_timeout (d, &mhd_timeout) == MHD_YES) 764 if (MHD_get_timeout64 (d, &mhd_timeout) == MHD_YES)
765 { 765 {
766 tv.tv_sec = mhd_timeout / 1000; 766 tv.tv_sec = mhd_timeout / 1000;
767 tv.tv_usec = (mhd_timeout - (tv.tv_sec * 1000)) * 1000; 767 tv.tv_usec = (mhd_timeout - (tv.tv_sec * 1000)) * 1000;
diff --git a/src/examples/suspend_resume_epoll.c b/src/examples/suspend_resume_epoll.c
index b63f80be..87ec6521 100644
--- a/src/examples/suspend_resume_epoll.c
+++ b/src/examples/suspend_resume_epoll.c
@@ -174,16 +174,8 @@ main (int argc,
174 174
175 while (1) 175 while (1)
176 { 176 {
177 int timeout; 177 current_event_count = epoll_wait (epfd, events_list, 1,
178 MHD_UNSIGNED_LONG_LONG to; 178 MHD_get_timeout_i (d));
179
180 if (MHD_YES !=
181 MHD_get_timeout (d,
182 &to))
183 timeout = TIMEOUT_INFINITE;
184 else
185 timeout = (to < INT_MAX - 1) ? (int) to : (INT_MAX - 1);
186 current_event_count = epoll_wait (epfd, events_list, 1, timeout);
187 179
188 if (1 == current_event_count) 180 if (1 == current_event_count)
189 { 181 {
diff --git a/src/microhttpd/test_client_put_stop.c b/src/microhttpd/test_client_put_stop.c
index 09845ff9..dfd6af2e 100644
--- a/src/microhttpd/test_client_put_stop.c
+++ b/src/microhttpd/test_client_put_stop.c
@@ -1408,10 +1408,9 @@ performQueryExternal (struct MHD_Daemon *d, struct _MHD_dumbClient *clnt)
1408 { 1408 {
1409 /* client has finished, check whether MHD is still 1409 /* client has finished, check whether MHD is still
1410 * processing any connections */ 1410 * processing any connections */
1411 unsigned long long to;
1412 full_req_sent = 1; 1411 full_req_sent = 1;
1413 do_client = 0; 1412 do_client = 0;
1414 if (client_accepted && (MHD_YES != MHD_get_timeout (d, &to))) 1413 if (client_accepted && (0 > MHD_get_timeout64s (d)))
1415 { 1414 {
1416 ret = 0; 1415 ret = 0;
1417 break; /* MHD finished as well */ 1416 break; /* MHD finished as well */
diff --git a/src/microhttpd/test_set_panic.c b/src/microhttpd/test_set_panic.c
index 2d81c620..b1a24000 100644
--- a/src/microhttpd/test_set_panic.c
+++ b/src/microhttpd/test_set_panic.c
@@ -1179,10 +1179,9 @@ performQueryExternal (struct MHD_Daemon *d, struct _MHD_dumbClient *clnt)
1179 { 1179 {
1180 /* client has finished, check whether MHD is still 1180 /* client has finished, check whether MHD is still
1181 * processing any connections */ 1181 * processing any connections */
1182 unsigned long long to;
1183 full_req_sent = 1; 1182 full_req_sent = 1;
1184 do_client = 0; 1183 do_client = 0;
1185 if (client_accepted && (MHD_YES != MHD_get_timeout (d, &to))) 1184 if (client_accepted && (0 > MHD_get_timeout64s (d)))
1186 { 1185 {
1187 ret = 0; 1186 ret = 0;
1188 break; /* MHD finished as well */ 1187 break; /* MHD finished as well */
diff --git a/src/microhttpd/test_upgrade.c b/src/microhttpd/test_upgrade.c
index 2ade5edd..5ceb6466 100644
--- a/src/microhttpd/test_upgrade.c
+++ b/src/microhttpd/test_upgrade.c
@@ -1095,7 +1095,7 @@ run_mhd_select_loop (struct MHD_Daemon *daemon)
1095 fd_set ws; 1095 fd_set ws;
1096 fd_set es; 1096 fd_set es;
1097 MHD_socket max_fd; 1097 MHD_socket max_fd;
1098 MHD_UNSIGNED_LONG_LONG to; 1098 uint64_t to64;
1099 struct timeval tv; 1099 struct timeval tv;
1100 1100
1101 while (! done) 1101 while (! done)
@@ -1104,7 +1104,7 @@ run_mhd_select_loop (struct MHD_Daemon *daemon)
1104 FD_ZERO (&ws); 1104 FD_ZERO (&ws);
1105 FD_ZERO (&es); 1105 FD_ZERO (&es);
1106 max_fd = MHD_INVALID_SOCKET; 1106 max_fd = MHD_INVALID_SOCKET;
1107 to = 1000; 1107 to64 = 1000;
1108 1108
1109 if (MHD_YES != 1109 if (MHD_YES !=
1110 MHD_get_fdset (daemon, 1110 MHD_get_fdset (daemon,
@@ -1113,12 +1113,12 @@ run_mhd_select_loop (struct MHD_Daemon *daemon)
1113 &es, 1113 &es,
1114 &max_fd)) 1114 &max_fd))
1115 mhdErrorExitDesc ("MHD_get_fdset() failed"); 1115 mhdErrorExitDesc ("MHD_get_fdset() failed");
1116 (void) MHD_get_timeout (daemon, 1116 (void) MHD_get_timeout64 (daemon,
1117 &to); 1117 &to64);
1118 if (1000 < to) 1118 if (1000 < to64)
1119 to = 1000; 1119 to64 = 1000;
1120 tv.tv_sec = to / 1000; 1120 tv.tv_sec = to64 / 1000;
1121 tv.tv_usec = 1000 * (to % 1000); 1121 tv.tv_usec = 1000 * (to64 % 1000);
1122 if (0 > MHD_SYS_select_ (max_fd + 1, 1122 if (0 > MHD_SYS_select_ (max_fd + 1,
1123 &rs, 1123 &rs,
1124 &ws, 1124 &ws,
@@ -1173,7 +1173,7 @@ run_mhd_epoll_loop (struct MHD_Daemon *daemon)
1173 const union MHD_DaemonInfo *di; 1173 const union MHD_DaemonInfo *di;
1174 MHD_socket ep; 1174 MHD_socket ep;
1175 fd_set rs; 1175 fd_set rs;
1176 MHD_UNSIGNED_LONG_LONG to; 1176 uint64_t to64;
1177 struct timeval tv; 1177 struct timeval tv;
1178 int ret; 1178 int ret;
1179 1179
@@ -1185,15 +1185,15 @@ run_mhd_epoll_loop (struct MHD_Daemon *daemon)
1185 while (! done) 1185 while (! done)
1186 { 1186 {
1187 FD_ZERO (&rs); 1187 FD_ZERO (&rs);
1188 to = 1000; 1188 to64 = 1000;
1189 1189
1190 FD_SET (ep, &rs); 1190 FD_SET (ep, &rs);
1191 (void) MHD_get_timeout (daemon, 1191 (void) MHD_get_timeout64 (daemon,
1192 &to); 1192 &to64);
1193 if (1000 < to) 1193 if (1000 < to64)
1194 to = 1000; 1194 to64 = 1000;
1195 tv.tv_sec = to / 1000; 1195 tv.tv_sec = to64 / 1000;
1196 tv.tv_usec = 1000 * (to % 1000); 1196 tv.tv_usec = 1000 * (to64 % 1000);
1197 ret = select (ep + 1, 1197 ret = select (ep + 1,
1198 &rs, 1198 &rs,
1199 NULL, 1199 NULL,
diff --git a/src/microhttpd/test_upgrade_large.c b/src/microhttpd/test_upgrade_large.c
index 83ab50ca..312a3448 100644
--- a/src/microhttpd/test_upgrade_large.c
+++ b/src/microhttpd/test_upgrade_large.c
@@ -1278,7 +1278,7 @@ run_mhd_select_loop (struct MHD_Daemon *daemon)
1278 fd_set ws; 1278 fd_set ws;
1279 fd_set es; 1279 fd_set es;
1280 MHD_socket max_fd; 1280 MHD_socket max_fd;
1281 MHD_UNSIGNED_LONG_LONG to; 1281 uint64_t to64;
1282 struct timeval tv; 1282 struct timeval tv;
1283 1283
1284 while (! done) 1284 while (! done)
@@ -1287,7 +1287,7 @@ run_mhd_select_loop (struct MHD_Daemon *daemon)
1287 FD_ZERO (&ws); 1287 FD_ZERO (&ws);
1288 FD_ZERO (&es); 1288 FD_ZERO (&es);
1289 max_fd = MHD_INVALID_SOCKET; 1289 max_fd = MHD_INVALID_SOCKET;
1290 to = 1000; 1290 to64 = 1000;
1291 1291
1292 FD_SET (MHD_itc_r_fd_ (kicker), &rs); 1292 FD_SET (MHD_itc_r_fd_ (kicker), &rs);
1293 if (MHD_YES != 1293 if (MHD_YES !=
@@ -1297,12 +1297,12 @@ run_mhd_select_loop (struct MHD_Daemon *daemon)
1297 &es, 1297 &es,
1298 &max_fd)) 1298 &max_fd))
1299 mhdErrorExitDesc ("MHD_get_fdset() failed"); 1299 mhdErrorExitDesc ("MHD_get_fdset() failed");
1300 (void) MHD_get_timeout (daemon, 1300 (void) MHD_get_timeout64 (daemon,
1301 &to); 1301 &to64);
1302 if (1000 < to) 1302 if (1000 < to64)
1303 to = 1000; 1303 to64 = 1000;
1304 tv.tv_sec = to / 1000; 1304 tv.tv_sec = to64 / 1000;
1305 tv.tv_usec = 1000 * (to % 1000); 1305 tv.tv_usec = 1000 * (to64 % 1000);
1306 if (0 > MHD_SYS_select_ (max_fd + 1, 1306 if (0 > MHD_SYS_select_ (max_fd + 1,
1307 &rs, 1307 &rs,
1308 &ws, 1308 &ws,
@@ -1359,7 +1359,7 @@ run_mhd_epoll_loop (struct MHD_Daemon *daemon)
1359 const union MHD_DaemonInfo *di; 1359 const union MHD_DaemonInfo *di;
1360 MHD_socket ep; 1360 MHD_socket ep;
1361 fd_set rs; 1361 fd_set rs;
1362 MHD_UNSIGNED_LONG_LONG to; 1362 uint64_t to64;
1363 struct timeval tv; 1363 struct timeval tv;
1364 int ret; 1364 int ret;
1365 1365
@@ -1371,15 +1371,15 @@ run_mhd_epoll_loop (struct MHD_Daemon *daemon)
1371 while (! done) 1371 while (! done)
1372 { 1372 {
1373 FD_ZERO (&rs); 1373 FD_ZERO (&rs);
1374 to = 1000; 1374 to64 = 1000;
1375 FD_SET (MHD_itc_r_fd_ (kicker), &rs); 1375 FD_SET (MHD_itc_r_fd_ (kicker), &rs);
1376 FD_SET (ep, &rs); 1376 FD_SET (ep, &rs);
1377 (void) MHD_get_timeout (daemon, 1377 (void) MHD_get_timeout64 (daemon,
1378 &to); 1378 &to64);
1379 if (1000 < to) 1379 if (1000 < to64)
1380 to = 1000; 1380 to64 = 1000;
1381 tv.tv_sec = to / 1000; 1381 tv.tv_sec = to64 / 1000;
1382 tv.tv_usec = 1000 * (to % 1000); 1382 tv.tv_usec = 1000 * (to64 % 1000);
1383 ret = select (ep + 1, 1383 ret = select (ep + 1,
1384 &rs, 1384 &rs,
1385 NULL, 1385 NULL,
diff --git a/src/testcurl/perf_get_concurrent.c b/src/testcurl/perf_get_concurrent.c
index ea282874..80f66eea 100644
--- a/src/testcurl/perf_get_concurrent.c
+++ b/src/testcurl/perf_get_concurrent.c
@@ -413,7 +413,7 @@ testExternalGet (int port)
413 fd_set es; 413 fd_set es;
414 MHD_socket max; 414 MHD_socket max;
415 struct timeval tv; 415 struct timeval tv;
416 MHD_UNSIGNED_LONG_LONG tt; 416 uint64_t tt64;
417 int tret; 417 int tret;
418 char *ret_val; 418 char *ret_val;
419 int ret = 0; 419 int ret = 0;
@@ -455,11 +455,11 @@ testExternalGet (int port)
455 MHD_stop_daemon (d); 455 MHD_stop_daemon (d);
456 return 4096; 456 return 4096;
457 } 457 }
458 tret = MHD_get_timeout (d, &tt); 458 tret = MHD_get_timeout64 (d, &tt64);
459 if (MHD_YES != tret) 459 if (MHD_YES != tret)
460 tt = 1; 460 tt64 = 1;
461 tv.tv_sec = tt / 1000; 461 tv.tv_sec = tt64 / 1000;
462 tv.tv_usec = 1000 * (tt % 1000); 462 tv.tv_usec = 1000 * (tt64 % 1000);
463 if (-1 == select (max + 1, &rs, &ws, &es, &tv)) 463 if (-1 == select (max + 1, &rs, &ws, &es, &tv))
464 { 464 {
465#ifdef MHD_POSIX_SOCKETS 465#ifdef MHD_POSIX_SOCKETS
diff --git a/src/testcurl/test_get_close_keep_alive.c b/src/testcurl/test_get_close_keep_alive.c
index 8f83fa1d..7857f2ad 100644
--- a/src/testcurl/test_get_close_keep_alive.c
+++ b/src/testcurl/test_get_close_keep_alive.c
@@ -562,8 +562,7 @@ performQueryExternal (struct MHD_Daemon *d, CURL *c)
562 } 562 }
563 if (NULL == multi) 563 if (NULL == multi)
564 { /* libcurl has finished, check whether MHD still needs to perform cleanup */ 564 { /* libcurl has finished, check whether MHD still needs to perform cleanup */
565 unsigned long long to; 565 if (0 != MHD_get_timeout64s (d))
566 if ((MHD_YES != MHD_get_timeout (d, &to)) || (0 != to))
567 break; /* MHD finished as well */ 566 break; /* MHD finished as well */
568 } 567 }
569 if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &maxMhdSk)) 568 if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &maxMhdSk))
diff --git a/src/testcurl/test_post_loop.c b/src/testcurl/test_post_loop.c
index c36fba7f..37cd121b 100644
--- a/src/testcurl/test_post_loop.c
+++ b/src/testcurl/test_post_loop.c
@@ -413,7 +413,7 @@ testExternalPost ()
413 time_t start; 413 time_t start;
414 struct timeval tv; 414 struct timeval tv;
415 int i; 415 int i;
416 unsigned long long timeout; 416 uint64_t timeout64;
417 long ctimeout; 417 long ctimeout;
418 char url[1024]; 418 char url[1024];
419 int port; 419 int port;
@@ -516,15 +516,15 @@ testExternalPost ()
516 MHD_stop_daemon (d); 516 MHD_stop_daemon (d);
517 return 4096; 517 return 4096;
518 } 518 }
519 if (MHD_NO == MHD_get_timeout (d, &timeout)) 519 if (MHD_NO == MHD_get_timeout64 (d, &timeout64))
520 timeout = 100; /* 100ms == INFTY -- CURL bug... */ 520 timeout64 = 100; /* 100ms == INFTY -- CURL bug... */
521 if ((CURLM_OK == curl_multi_timeout (multi, &ctimeout)) && 521 if ((CURLM_OK == curl_multi_timeout (multi, &ctimeout)) &&
522 (ctimeout < (long long) timeout) && (ctimeout >= 0)) 522 (ctimeout >= 0) && ((uint64_t) ctimeout < timeout64))
523 timeout = ctimeout; 523 timeout64 = (uint64_t) ctimeout;
524 if ( (c == NULL) || (0 == running) ) 524 if ( (c == NULL) || (0 == running) )
525 timeout = 0; /* terminate quickly... */ 525 timeout64 = 0; /* terminate quickly... */
526 tv.tv_sec = timeout / 1000; 526 tv.tv_sec = timeout64 / 1000;
527 tv.tv_usec = (timeout % 1000) * 1000; 527 tv.tv_usec = (timeout64 % 1000) * 1000;
528 if (-1 == select (maxposixs + 1, &rs, &ws, &es, &tv)) 528 if (-1 == select (maxposixs + 1, &rs, &ws, &es, &tv))
529 { 529 {
530#ifdef MHD_POSIX_SOCKETS 530#ifdef MHD_POSIX_SOCKETS
diff --git a/src/testcurl/test_toolarge.c b/src/testcurl/test_toolarge.c
index d8bfaef6..42ea471f 100644
--- a/src/testcurl/test_toolarge.c
+++ b/src/testcurl/test_toolarge.c
@@ -661,8 +661,7 @@ performQueryExternal (struct MHD_Daemon *d, CURL *c)
661 } 661 }
662 if (NULL == multi) 662 if (NULL == multi)
663 { /* libcurl has finished, check whether MHD still needs to perform cleanup */ 663 { /* libcurl has finished, check whether MHD still needs to perform cleanup */
664 unsigned long long to; 664 if (0 != MHD_get_timeout64s (d))
665 if ((MHD_YES != MHD_get_timeout (d, &to)) || (0 != to))
666 break; /* MHD finished as well */ 665 break; /* MHD finished as well */
667 } 666 }
668 if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &maxMhdSk)) 667 if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &maxMhdSk))
diff --git a/src/testcurl/test_tricky.c b/src/testcurl/test_tricky.c
index 1aca7dce..5bc28323 100644
--- a/src/testcurl/test_tricky.c
+++ b/src/testcurl/test_tricky.c
@@ -591,8 +591,7 @@ performQueryExternal (struct MHD_Daemon *d, CURL *c)
591 } 591 }
592 if (NULL == multi) 592 if (NULL == multi)
593 { /* libcurl has finished, check whether MHD still needs to perform cleanup */ 593 { /* libcurl has finished, check whether MHD still needs to perform cleanup */
594 unsigned long long to; 594 if (0 != MHD_get_timeout64s (d))
595 if ((MHD_YES != MHD_get_timeout (d, &to)) || (0 != to))
596 break; /* MHD finished as well */ 595 break; /* MHD finished as well */
597 } 596 }
598 if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &maxMhdSk)) 597 if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &maxMhdSk))